{"id":18676945,"url":"https://github.com/ecies/js-ciphers","last_synced_at":"2025-04-12T02:33:05.654Z","repository":{"id":257822062,"uuid":"871090124","full_name":"ecies/js-ciphers","owner":"ecies","description":"Node/Pure JavaScript symmetric ciphers adapter","archived":false,"fork":false,"pushed_at":"2024-10-30T11:09:27.000Z","size":54,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-30T12:17:18.442Z","etag":null,"topics":["aes","cryptography"],"latest_commit_sha":null,"homepage":"https://ecies.org/js-ciphers","language":"TypeScript","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/ecies.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":"kigawas"}},"created_at":"2024-10-11T08:50:56.000Z","updated_at":"2024-10-19T02:59:20.000Z","dependencies_parsed_at":"2024-10-30T12:17:18.325Z","dependency_job_id":"da210aae-4e7b-4622-8157-f03d1fb20645","html_url":"https://github.com/ecies/js-ciphers","commit_stats":null,"previous_names":["ecies/js-ciphers"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ecies%2Fjs-ciphers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ecies%2Fjs-ciphers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ecies%2Fjs-ciphers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ecies%2Fjs-ciphers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ecies","download_url":"https://codeload.github.com/ecies/js-ciphers/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223489807,"owners_count":17153831,"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":["aes","cryptography"],"created_at":"2024-11-07T09:31:52.164Z","updated_at":"2025-04-12T02:33:05.646Z","avatar_url":"https://github.com/ecies.png","language":"TypeScript","funding_links":["https://github.com/sponsors/kigawas"],"categories":[],"sub_categories":[],"readme":"# @ecies/ciphers\n\n[![License](https://img.shields.io/github/license/ecies/js-ciphers.svg)](https://github.com/ecies/js-ciphers)\n[![NPM Package](https://img.shields.io/npm/v/@ecies/ciphers.svg)](https://www.npmjs.com/package/@ecies/ciphers)\n[![NPM Downloads](https://img.shields.io/npm/dm/@ecies/ciphers)](https://npm-stat.link/@ecies/ciphers)\n[![Install size](https://packagephobia.com/badge?p=@ecies/ciphers)](https://packagephobia.com/result?p=@ecies/ciphers)\n[![CI](https://img.shields.io/github/actions/workflow/status/ecies/js-ciphers/ci.yml)](https://github.com/ecies/js-ciphers/actions)\n[![Codecov](https://img.shields.io/codecov/c/github/ecies/js-ciphers.svg)](https://codecov.io/gh/ecies/js-ciphers)\n\nNode/Pure JavaScript symmetric ciphers adapter.\n\nIf native implementations are available on some platforms (e.g. node, deno, bun), it'll use [`node:crypto`](https://nodejs.org/api/crypto.html#cryptocreatecipherivalgorithm-key-iv-options) for efficiency.\n\nOtherwise (e.g. browser, react native), it'll use [`@noble/ciphers`](https://github.com/paulmillr/noble-ciphers) for compatibility.\n\n|              | aes              | chacha           |\n| ------------ | ---------------- | ---------------- |\n| Node         | `node:crypto` ⚡ | `node:crypto` ⚡ |\n| Bun          | `node:crypto` ⚡ | `@noble/ciphers` |\n| Deno         | `node:crypto` ⚡ | `@noble/ciphers` |\n| Browser      | `@noble/ciphers` | `@noble/ciphers` |\n| React Native | `@noble/ciphers` | `@noble/ciphers` |\n\n\u003e [!NOTE]\n\u003e You may need to polyfill [`crypto.getRandomValues`](https://github.com/LinusU/react-native-get-random-values) for React Native.\n\u003e\n\u003e There are some limitations, see [Known limitations](#known-limitations) below.\n\u003e\n\u003e This library is tree-shakeable, unused code will be excluded by bundlers.\n\nCheck the [example](./example/) folder for bun/deno usage.\n\n## Quick start\n\n```js\nimport { aes256gcm } from \"@ecies/ciphers/aes\";\nimport { randomBytes } from \"@noble/ciphers/webcrypto\";\n\nconst TEXT = \"hello world🌍!\";\nconst encoder = new TextEncoder();\nconst decoder = new TextDecoder();\nconst msg = encoder.encode(TEXT);\n\nconst key = randomBytes();\nconst nonce = randomBytes(16);\nconst cipher = aes256gcm(key, nonce);\nconsole.log(\"decrypted:\", decoder.decode(cipher.decrypt(cipher.encrypt(msg))));\n```\n\nThe API follows `@noble/ciphers`'s API for ease of use, you can check their [examples](https://github.com/paulmillr/noble-ciphers#examples) as well.\n\n## Supported ciphers\n\n- `aes-256-gcm`\n  - Both 16 bytes and 12 bytes nonce are supported.\n- `aes-256-cbc`\n  - **Only for legacy applications**. You should use `xchacha20-poly1305` or `aes-256-gcm` as possible.\n  - Nonce is always 16 bytes.\n- `chacha20-poly1305`\n  - Nonce is always 12 bytes.\n- `xchacha20-poly1305`\n  - Nonce is always 24 bytes.\n\nIf key is fixed and nonce is less than 16 bytes, avoid randomly generated nonce.\n\n## Known limitations\n\n- `xchacha20-poly1305` is implemented with pure JS [`hchacha20`](https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-xchacha#section-2.2) function and `node:crypto`'s `chacha20-poly1305` on node.\n- Currently (Mar 2025), `node:crypto`'s `chacha20-poly1305` is not supported on deno and [bun](https://github.com/oven-sh/bun/issues/8072), `@noble/ciphers`'s implementation is used on both platforms instead.\n- Some old versions of `deno` [do not support](https://github.com/denoland/deno/discussions/17964#discussioncomment-10917259) **indirect** conditional exports. If you use this library to build another library, client code of your library may fall back to the `node:crypto` implementation and not work properly, specifically `aes-256-gcm` (16 bytes nonce) and `chacha20-poly1305`. If you found such a problem, upgrade deno to the latest version.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fecies%2Fjs-ciphers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fecies%2Fjs-ciphers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fecies%2Fjs-ciphers/lists"}