# chacha20-universal

> chacha20 in pure javascript

Latest version **1.0.4** (published 2020-06-18) · ISC license · 0 weekly downloads

## Install

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

## Health

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

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2020-06-18 |
| First published | 2020-06-17 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | separate (@types/chacha20-universal) |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 27.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Christophe Diederichs |
| Maintainers | chm-diederichs |
| Keywords | chacha20 |

## Links

- npm: https://www.npmjs.com/package/chacha20-universal
- Repository: https://github.com/chm-diederichs/chacha20-universal
- Homepage: https://github.com/chm-diederichs/chacha20-universal#readme
- Issues: https://github.com/chm-diederichs/chacha20-universal/issues
- npm.io page: https://npm.io/package/chacha20-universal

## Dependencies (1)

- [nanoassert](https://npm.io/package/nanoassert.md) ^2.0.0

## Recent versions

- 1.0.4 (latest) — 2020-06-18
- 1.0.3 — 2020-06-17
- 1.0.2 — 2020-06-17
- 1.0.1 — 2020-06-17
- 1.0.0 — 2020-06-17

## README

# chacha20-universal

Chacha20 implemented in Javascript.

```
npm install chacha20-universal
```

## Usage

``` js
var crypto = require('crypto')
var Chacha20 = require('chacha20')

var key = crypto.randomBytes(32)
var nonce = crypto.randomBytes(24)
var out = Buffer.alloc(5)
var xor = new Chacha20(nonce, key)

xor.update(out, Buffer.from('hello'))
xor.update(out, Buffer.from('world'))

console.log(out)
// e.g. <Buffer 7c 77 23 51 f9>

xor.finalize()
```

## API

#### `var xor = chacha20(nonce, key, [counter])`

Create a new xor instance.

`nonce` should be a 12 byte buffer/uint8array and `key` should be 32 byte. An optional `counter` may be passed as a number.

#### `xor.update(output, input)`

Update the xor instance with a new `input` buffer, the result is written to `output` buffer. `output` should be the same byte length as `input`.

#### `xor.final()`

Call this method last. Clears internal state.

## License

MIT

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