{"id":22190880,"url":"https://github.com/appsup-dart/crypto_keys","last_synced_at":"2025-07-26T22:31:10.367Z","repository":{"id":43052416,"uuid":"155891802","full_name":"appsup-dart/crypto_keys","owner":"appsup-dart","description":"A library for doing cryptographic signing/verifying and encrypting/decrypting.","archived":false,"fork":false,"pushed_at":"2024-03-07T11:56:03.000Z","size":108,"stargazers_count":12,"open_issues_count":2,"forks_count":18,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-06-19T04:24:51.541Z","etag":null,"topics":["cryptography","rsa"],"latest_commit_sha":null,"homepage":"","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/appsup-dart.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-11-02T16:18:42.000Z","updated_at":"2024-04-01T17:07:53.000Z","dependencies_parsed_at":"2024-06-19T04:12:50.839Z","dependency_job_id":"0f59806b-d920-43d8-8f22-e57fb2be25bb","html_url":"https://github.com/appsup-dart/crypto_keys","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appsup-dart%2Fcrypto_keys","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appsup-dart%2Fcrypto_keys/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appsup-dart%2Fcrypto_keys/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appsup-dart%2Fcrypto_keys/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/appsup-dart","download_url":"https://codeload.github.com/appsup-dart/crypto_keys/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227724209,"owners_count":17810036,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cryptography","rsa"],"created_at":"2024-12-02T12:13:10.521Z","updated_at":"2024-12-02T12:13:11.236Z","avatar_url":"https://github.com/appsup-dart.png","language":"Dart","funding_links":["https://github.com/sponsors/rbellens"],"categories":[],"sub_categories":[],"readme":"\n[![Build Status](https://travis-ci.org/appsup-dart/crypto_keys.svg?branch=master)](https://travis-ci.org/appsup-dart/crypto_keys)\n[:heart: sponsor](https://github.com/sponsors/rbellens)\n\nA library for doing cryptographic signing/verifying and encrypting/decrypting.\n\nIt uses `pointycastle` under the hood, but exposes a more convenient \napi.\n\n\n\n## Usage\n\n### Signing \n\nA simple usage example:\n\n```dart\nimport 'package:crypto_keys/crypto_keys.dart';\nimport 'dart:typed_data';\n\nmain() {\n  // Create a key pair from a JWK representation\n  var keyPair = new KeyPair.fromJwk({\n    \"kty\": \"oct\",\n    \"k\": \"AyM1SysPpbyDfgZld3umj1qzKObwVMkoqQ-EstJQLr_T-1qS0gZH75\"\n        \"aKtMN3Yj0iPS4hcgUuTwjAzZr1Z9CAow\"\n  });\n\n  // A key pair has a private and public key, possibly one of them is null, if\n  // required info was not available when construction\n  // The private key can be used for signing\n  var privateKey = keyPair.privateKey;\n\n  // Create a signer for the key using the HMAC/SHA-256 algorithm\n  var signer = privateKey.createSigner(algorithms.signing.hmac.sha256);\n\n  // Sign some content, to be integrity protected\n  var content = \"It's me, really me\";\n  var signature = signer.sign(\"It's me, really me\".codeUnits);\n\n  print(\"Signing '$content'\");\n  print(\"Signature: ${signature.data}\");\n\n  // The public key can be used for verifying the signature\n  var publicKey = keyPair.publicKey;\n\n  // Create a verifier for the key using the specified algorithm\n  var verifier = publicKey.createVerifier(algorithms.signing.hmac.sha256);\n\n  var verified =\n      verifier.verify(new Uint8List.fromList(content.codeUnits), signature);\n  if (verified)\n    print(\"Verification succeeded\");\n  else\n    print(\"Verification failed\");\n}\n```\n\n### Encryption\n\nA simple usage example:\n\n```dart\n\nimport 'package:crypto_keys/crypto_keys.dart';\nimport 'dart:typed_data';\n\nmain() {\n  // Generate a new random symmetric key pair\n  var keyPair = new KeyPair.generateSymmetric(128);\n\n  // Use the public key to create an encrypter with the AES/GCM algorithm\n  var encrypter =\n      keyPair.publicKey.createEncrypter(algorithms.encryption.aes.gcm);\n\n  // Encrypt the content with an additional authentication data for integrity\n  // protection\n  var content = \"A very secret text\";\n  var aad = \"It is me\";\n  var v = encrypter.encrypt(new Uint8List.fromList(content.codeUnits),\n      additionalAuthenticatedData: new Uint8List.fromList(aad.codeUnits));\n\n  print(\"Encrypting '$content'\");\n  print(\"Ciphertext: ${v.data}\");\n  print(\"Authentication tag: ${v.authenticationTag}\");\n\n  // Use the private key to create the decrypter\n  var decrypter =\n      keyPair.privateKey.createEncrypter(algorithms.encryption.aes.gcm);\n\n  // Decrypt and verify authentication tag\n  var decrypted = decrypter.decrypt(v);\n\n  print(\"Decrypted text: '${new String.fromCharCodes(decrypted)}'\");\n}\n\n```\n\n## Features and bugs\n\nPlease file feature requests and bugs at the [issue tracker][tracker].\n\n[tracker]: https://github.com/appsup-dart/crypto_keys/issues\n\n\n## Sponsor\n\nCreating and maintaining this package takes a lot of time. If you like the result, please consider to [:heart: sponsor](https://github.com/sponsors/rbellens). \nWith your support, I will be able to further improve and support this project.\nAlso, check out my other dart packages at [pub.dev](https://pub.dev/packages?q=publisher%3Aappsup.be).\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fappsup-dart%2Fcrypto_keys","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fappsup-dart%2Fcrypto_keys","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fappsup-dart%2Fcrypto_keys/lists"}