|
2 | 2 |
|
3 | 3 | [](https://github.com/ecies/js-ciphers)
|
4 | 4 | [](https://www.npmjs.com/package/@ecies/ciphers)
|
5 |
| - |
| 5 | +[](https://npm-stat.link/@ecies/ciphers) |
6 | 6 | [](https://packagephobia.com/result?p=@ecies/ciphers)
|
7 | 7 | [](https://github.com/ecies/js-ciphers/actions)
|
8 | 8 | [](https://codecov.io/gh/ecies/js-ciphers)
|
9 | 9 |
|
10 | 10 | Node/Pure JavaScript symmetric ciphers adapter.
|
11 | 11 |
|
12 |
| -On browsers (or React Native, deno), it'll use [`@noble/ciphers`](https://github.com/paulmillr/noble-ciphers)'s implementation for compatibility. |
| 12 | +If 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. |
13 | 13 |
|
14 |
| -On node (or bun), it'll use [`node:crypto`](https://nodejs.org/api/crypto.html#cryptocreatecipherivalgorithm-key-iv-options)'s implementation for efficiency. |
| 14 | +Otherwise (e.g. browser, react native), it'll use [`@noble/ciphers`](https://github.com/paulmillr/noble-ciphers) for compatibility. |
| 15 | + |
| 16 | +| | aes | chacha | |
| 17 | +| ------------ | ---------------- | ---------------- | |
| 18 | +| Node | `node:crypto` ⚡ | `node:crypto` ⚡ | |
| 19 | +| Bun | `node:crypto` ⚡ | `@noble/ciphers` | |
| 20 | +| Deno | `node:crypto` ⚡ | `@noble/ciphers` | |
| 21 | +| Browser | `@noble/ciphers` | `@noble/ciphers` | |
| 22 | +| React Native | `@noble/ciphers` | `@noble/ciphers` | |
15 | 23 |
|
16 | 24 | > [!NOTE]
|
17 | 25 | > You may need to polyfill [`crypto.getRandomValues`](https://github.com/LinusU/react-native-get-random-values) for React Native.
|
@@ -58,5 +66,5 @@ If key is fixed and nonce is less than 16 bytes, avoid randomly generated nonce.
|
58 | 66 | ## Known limitations
|
59 | 67 |
|
60 | 68 | - `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.
|
61 |
| -- Currently (Nov 2024), `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. |
62 |
| -- `deno` does not support **indirect** conditional exports. If you use this library to build another library, client code of your library probably falls back to the `node:crypto` implementation and may not work properly, specifically `aes-256-gcm` (16 bytes nonce) and `chacha20-poly1305`. |
| 69 | +- 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. |
| 70 | +- 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`. |
0 commit comments