{"id":17857802,"url":"https://github.com/queicherius/asymmetric-crypto","last_synced_at":"2025-03-20T15:33:01.687Z","repository":{"id":43921683,"uuid":"78567823","full_name":"queicherius/asymmetric-crypto","owner":"queicherius","description":"Encryption and signing using public-key cryptography (via tweetnacl)","archived":false,"fork":false,"pushed_at":"2020-05-11T17:22:06.000Z","size":28,"stargazers_count":16,"open_issues_count":3,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-10-13T03:18:48.305Z","etag":null,"topics":["maintained","npm-package"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/queicherius.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-01-10T19:45:47.000Z","updated_at":"2024-09-15T04:19:53.000Z","dependencies_parsed_at":"2022-08-24T08:30:57.516Z","dependency_job_id":null,"html_url":"https://github.com/queicherius/asymmetric-crypto","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/queicherius%2Fasymmetric-crypto","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/queicherius%2Fasymmetric-crypto/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/queicherius%2Fasymmetric-crypto/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/queicherius%2Fasymmetric-crypto/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/queicherius","download_url":"https://codeload.github.com/queicherius/asymmetric-crypto/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221776164,"owners_count":16878490,"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":["maintained","npm-package"],"created_at":"2024-10-28T04:04:01.302Z","updated_at":"2024-10-28T04:04:01.958Z","avatar_url":"https://github.com/queicherius.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# asymmetric-crypto\n\n[![Build Status](https://img.shields.io/travis/queicherius/asymmetric-crypto.svg?style=flat-square)](https://travis-ci.org/queicherius/asymmetric-crypto)\n[![Coverage Status](https://img.shields.io/codecov/c/github/queicherius/asymmetric-crypto/master.svg?style=flat-square)](https://codecov.io/github/queicherius/asymmetric-crypto) [![Greenkeeper badge](https://badges.greenkeeper.io/queicherius/asymmetric-crypto.svg)](https://greenkeeper.io/)\n\n\u003e Encryption and signing using public-key cryptography (via [`tweetnacl`](https://github.com/dchest/tweetnacl-js))\n\n## Install\n\n```\nnpm install asymmetric-crypto\n```\n\nThis module can be used for Node.js as well as browsers using [Browserify](https://github.com/substack/browserify-handbook#how-node_modules-works).\n\n## Usage\n\n```js\nconst crypto = require('asymmetric-crypto')\n\n// Generate a key pair\nconst keyPair = crypto.keyPair()\n// -\u003e {\n//   secretKey: 'KOy7fMWMkRc+QX8dzpfX9VwJKlc/+Zkyw5C7RGTXT920IjiKUdOSe/3sNnrETw7ej9TBFzsPyRfkWGMsGLAufQ==',\n//   publicKey: 'tCI4ilHTknv97DZ6xE8O3o/UwRc7D8kX5FhjLBiwLn0='\n// }\n\n// Regenerate a key pair from the secret key\nconst newKeyPair = crypto.fromSecretKey(keyPair.secretKey)\n// -\u003e {\n//   secretKey: 'KOy7fMWMkRc+QX8dzpfX9VwJKlc/+Zkyw5C7RGTXT920IjiKUdOSe/3sNnrETw7ej9TBFzsPyRfkWGMsGLAufQ==',\n//   publicKey: 'tCI4ilHTknv97DZ6xE8O3o/UwRc7D8kX5FhjLBiwLn0='\n// }\n\nconst myKeyPair = crypto.keyPair()\nconst theirKeyPair = crypto.keyPair()\n\n// Encrypt data\nconst encrypted = crypto.encrypt('some data', theirKeyPair.publicKey, myKeyPair.secretKey)\n// -\u003e {\n//   data: '63tP2r8WQuJ+k+jzsd8pbT6WYPHMTafpeg==',\n//   nonce: 'BDHALdoeBiGg7wJbVdfJhVQQyvpxrBSo'\n// }\n\n// Decrypt data\nconst decrypted = crypto.decrypt(encrypted.data, encrypted.nonce, myKeyPair.publicKey, theirKeyPair.secretKey)\n// -\u003e 'some data'\n\n// Sign a message\nconst message = 'some message'\nconst signature = crypto.sign(message, myKeyPair.secretKey)\n// -\u003e '8oz1aNkSBG1qvYhc+E2VBkgHSxCORGdsyf7LFQuLDmZvJt6vaEzHMIsofmTykMunhCrChEHT9Fgw3sp/W6+7Bw=='\n\n// Verify the signature on a message\nconst validSignature = crypto.verify(message, signature, myKeyPair.publicKey)\n// -\u003e true\n```\n\n## Tests\n\n```\nnpm test\n```\n\n## Internals\n\n- [`tweetnacl`](https://github.com/dchest/tweetnacl-js) for the cryptographic implementation\n- [`tweetnacl-util`](https://github.com/dchest/tweetnacl-util-js) for converting into / from strings\n- [`ed2curve`](https://github.com/dchest/ed2curve-js) for converting *Ed25519* keys into *curve25519-xsalsa20-poly1305* keys (so you can encrypt and sign with the same key pair)\n- [`fast-memoize`](https://www.npmjs.com/package/fast-memoize) to make converting keys more efficient\n\n## Licence\n\nMIT\n\n---\n\nThanks to @pguth for the inspiration. :smile:\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqueicherius%2Fasymmetric-crypto","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fqueicherius%2Fasymmetric-crypto","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqueicherius%2Fasymmetric-crypto/lists"}