# @ecies/ciphers

> Node/Pure JavaScript symmetric ciphers adapter

Latest version **0.2.6** (published 2026-03-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install @ecies/ciphers
pnpm add @ecies/ciphers
yarn add @ecies/ciphers
bun add @ecies/ciphers
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; high maintenance score; high quality score.

Warnings: low downloads; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.2.6 |
| Published | 2026-03-31 |
| First published | 2024-10-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=16 |
| Dependencies | 0 |
| Unpacked size | 15.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 1 |
| Author | Weiliang Li |
| Maintainers | kigawas |
| Keywords | cryptography, cipher, aes, chacha, chacha20, chacha20poly1305, xchacha20, xchacha20poly1305 |

## Links

- npm: https://www.npmjs.com/package/@ecies/ciphers
- Repository: https://github.com/ecies/js-ciphers
- Homepage: https://github.com/ecies/js-ciphers#readme
- Issues: https://github.com/ecies/js-ciphers/issues
- npm.io page: https://npm.io/package/@ecies/ciphers

## Alternatives

- [@gemini-wallet/core](https://npm.io/package/@gemini-wallet/core.md) — 515.6K weekly downloads
- [utility](https://npm.io/package/utility.md) — 416.6K weekly downloads
- [@primno/dpapi](https://npm.io/package/@primno/dpapi.md) — 7.2K weekly downloads
- [pi-readseek](https://npm.io/package/pi-readseek.md) — 3.7K weekly downloads
- [@emilia-protocol/verify](https://npm.io/package/@emilia-protocol/verify.md) — 1.1K weekly downloads

## Recent versions

- 0.2.6 (latest) — 2026-03-31
- 0.2.5 — 2025-11-04
- 0.2.4 — 2025-07-05
- 0.2.3 — 2025-03-06
- 0.2.2 — 2024-11-28
- 0.2.1 — 2024-10-31
- 0.2.0 — 2024-10-19
- 0.1.0 — 2024-10-11

## README

# @ecies/ciphers

[![License](https://img.shields.io/github/license/ecies/js-ciphers.svg)](https://github.com/ecies/js-ciphers)
[![NPM Package](https://img.shields.io/npm/v/@ecies/ciphers.svg)](https://www.npmjs.com/package/@ecies/ciphers)
[![NPM Downloads](https://img.shields.io/npm/dm/@ecies/ciphers)](https://npm-stat.link/@ecies/ciphers)
[![Install size](https://packagephobia.com/badge?p=@ecies/ciphers)](https://packagephobia.com/result?p=@ecies/ciphers)
[![CI](https://img.shields.io/github/actions/workflow/status/ecies/js-ciphers/ci.yml)](https://github.com/ecies/js-ciphers/actions)
[![Codecov](https://img.shields.io/codecov/c/github/ecies/js-ciphers.svg)](https://codecov.io/gh/ecies/js-ciphers)

Node/Pure JavaScript symmetric ciphers adapter.

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.

Otherwise (e.g. browser, react native), it'll use [`@noble/ciphers`](https://github.com/paulmillr/noble-ciphers) for compatibility.

|              | aes              | chacha           |
| ------------ | ---------------- | ---------------- |
| Node         | `node:crypto` ⚡  | `node:crypto` ⚡  |
| Bun          | `node:crypto` ⚡  | `@noble/ciphers` |
| Deno         | `node:crypto` ⚡  | `node:crypto` ⚡  |
| Browser      | `@noble/ciphers` | `@noble/ciphers` |
| React Native | `@noble/ciphers` | `@noble/ciphers` |

> [!NOTE]
> You may need to polyfill [`crypto.getRandomValues`](https://github.com/LinusU/react-native-get-random-values) for React Native.
>
> There are some limitations, see [Known limitations](#known-limitations) below.
>
> This library is tree-shakeable, unused code will be excluded by bundlers.

Check the [example](./example/) folder for more usages.

## Quick start

```js
// example/quick-start.js
import { aes256gcm } from "@ecies/ciphers/aes";
import { randomBytes } from "@noble/ciphers/webcrypto";

const TEXT = "hello world🌍!";
const encoder = new TextEncoder();
const decoder = new TextDecoder();
const msg = encoder.encode(TEXT);

const key = randomBytes();
const nonce = randomBytes(16);
const cipher = aes256gcm(key, nonce);
console.log("decrypted:", decoder.decode(cipher.decrypt(cipher.encrypt(msg))));
```

The API follows `@noble/ciphers`'s API for ease of use, you can check their [examples](https://github.com/paulmillr/noble-ciphers#examples) as well.

## Supported ciphers

- `aes-256-gcm`
  - Both 16 bytes and 12 bytes nonce are supported.
- `aes-256-cbc`
  - **Only for legacy applications**. You should use `xchacha20-poly1305` or `aes-256-gcm` as possible.
  - Nonce is always 16 bytes.
- `chacha20-poly1305`
  - Nonce is always 12 bytes.
- `xchacha20-poly1305`
  - Nonce is always 24 bytes.

If key is fixed and nonce is less than 16 bytes, **avoid randomly generated nonce**.

## Known limitations

- `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/deno.
- Currently (Apr 2026), `node:crypto`'s `chacha20-poly1305` is not supported on [bun](https://github.com/oven-sh/bun/issues/8072), `@noble/ciphers`'s implementation is used instead. From deno 2.7.10, `node:crypto`'s `chacha20-poly1305` is [supported](https://github.com/denoland/deno/issues/28411). Please upgrade deno to use native implementation for better performance.
- Some old versions of `deno` [did not support](https://github.com/denoland/deno/discussions/17964#discussioncomment-10917259) **indirect** conditional exports. For example, if a library uses `@ecies/ciphers`, client code of that library might fall back to the `node:crypto` implementation and would not work properly, specifically `aes-256-gcm` and `chacha20-poly1305`. If you found such a problem, upgrade deno and run with `--conditions deno` (>=2.4.0) or `--unstable-node-conditions deno`(>=2.3.6,<2.4.0).

---
_Source: https://npm.io/package/@ecies/ciphers · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
