# chacha20

> A pure JavaScript implementation of the ChaCha20 cipher

Latest version **0.1.4** (published 2015-11-20) · CC0-1.0 license · 0 weekly downloads

## Install

```sh
npm install chacha20
pnpm add chacha20
yarn add chacha20
bun add chacha20
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.4 |
| Published | 2015-11-20 |
| First published | 2014-11-19 |
| Weekly downloads | 0 |
| License | CC0-1.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.10.x |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 25 |
| Author | Devi Mandiri |
| Maintainers | quartzjer |
| Keywords | chacha, chacha20, salsa20, browserify |

## Links

- npm: https://www.npmjs.com/package/chacha20
- Repository: https://github.com/quartzjer/chacha20
- Issues: https://github.com/quartzjer/chacha20/issues
- npm.io page: https://npm.io/package/chacha20

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 0.1.4 (latest) — 2015-11-20
- 0.1.3 — 2015-10-13
- 0.1.2 — 2014-11-19

## README

Pure javascript implementation of [ChaCha20](http://cr.yp.to/chacha.html) originally written by [@devi](https://github.com/devi/chacha20poly1305) supporting [draft-irtf-cfrg-chacha20-poly1305-01](https://tools.ietf.org/html/draft-irtf-cfrg-chacha20-poly1305-01).

Being packaged here as a simple node.js and browserify module.

## Usage

````
var chacha20 = require("chacha20");

var key = new Buffer(32);
key.fill(0);
var nonce = new Buffer(8);
nonce.fill(0);

var plaintext = "testing";
// pass in buffers, returns a buffer
var ciphertext = chacha20.encrypt(key, nonce, new Buffer(plaintext));
console.log(ciphertext.toString("hex")); // prints "02dd93d9c99f5a"
console.log(chacha20.decrypt(key, nonce, ciphertext).toString()); // prints "testing"
````

## Nonce Size

The handling of the nonce differs between the [reference](http://cr.yp.to/chacha.html) and [IETF Draft](https://tools.ietf.org/html/draft-irtf-cfrg-chacha20-poly1305-01#section-2.3), where the reference uses an 8-byte nonce and the draft uses a 12-byte one with the first 4 bytes being a `sender` unique identifier.  Passing a difference nonce buffer size will choose either mode.

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