# chloride

> node.js sodium bindings + pure js polyfil

Latest version **2.4.1** (published 2021-01-30) · MIT license · 0 weekly downloads

## Install

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

## 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 | 2.4.1 |
| Published | 2021-01-30 |
| First published | 2015-07-31 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/chloride) |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 8.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 90 |
| Author | Dominic Tarr |
| Maintainers | christianbundy, staltz, mixmix, andregarzia, arj03, dominictarr |
| Keywords | encryption, ed25519, curve25519, NaCl, libsodium, crypto, unique, stamp |

## Links

- npm: https://www.npmjs.com/package/chloride
- Repository: https://github.com/dominictarr/chloride
- Homepage: https://github.com/dominictarr/chloride#readme
- Issues: https://github.com/dominictarr/chloride/issues
- npm.io page: https://npm.io/package/chloride

## Dependencies (4)

- [sodium-native](https://npm.io/package/sodium-native.md) ^3.0.0
- [sodium-chloride](https://npm.io/package/sodium-chloride.md) ^1.1.2
- [sodium-browserify](https://npm.io/package/sodium-browserify.md) ^1.2.7
- [sodium-browserify-tweetnacl](https://npm.io/package/sodium-browserify-tweetnacl.md) ^0.2.5

## 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

- 2.4.1 (latest) — 2021-01-30
- 1.0.22-simple (simple) — 2015-10-16
- 2.4.0 — 2020-12-26
- 2.3.0 — 2020-08-20
- 2.2.14 — 2019-03-24
- 2.2.13 — 2019-03-21
- 2.2.12 — 2019-03-21
- 2.2.11 — 2019-03-12
- 2.2.10 — 2018-05-26
- 2.2.9 — 2018-04-10
- 2.2.8 — 2017-11-14
- 2.2.7 — 2017-05-28
- 2.2.6 — 2017-05-05
- 2.2.5 — 2017-05-03
- 2.2.4 — 2016-10-09
- … 16 more at https://npm.io/package/chloride/versions

## README

# Chloride

Chloride is a Cryptography Library (Cl) for javascript enviroments.

## About

Chloride descends from Dan J. Bernstein's (djb) [NaCl](http://nacl.cr.yp.to/) library ("Networking And Cryptography Library",
not to be confused with the other NaCl, Google's Native Client). djb wrote NaCl, but did not maintain it, some ideas in the library (in particular the networking part) weren't really fully baked, and the best parts where taken and maintained as [libsodium](http://libsodium.org) (although "Na" represents the element sodium, so they took the wrong part of the acronym).

Chloride is a compatibility layer that gives you bindings to [libsodium](https://npm.im/sodium) when used in Node.js,
and either the [libsodium-wrappers](https://npm.im/libsodium-wrappers) which is libsodium compiled to JavaScript via [emscripten](http://kripken.github.io/emscripten-site/) if performance is important but code size isn't.  Or, if you are not doing many crypto operations, it uses [tweetnacl](https://www.npmjs.com/package/tweetnacl), which is a handwritten port, and 1/10 the size of libsodium-wrappers.

## Support

We have wrapped and tested enough functions for our crypto modules to work.

  * [private-box](https://github.com/auditdrivencrypto/private-box): write a shortish message to multiple recipients.
  * [pull-box-stream](https://github.com/dominictarr/pull-box-stream): encrypt (every byte in) a one-way stream.
  * [secret-handshake](https://github.com/dominictarr/secret-handshake): create an authenticated private channel to a public key.

This is probably everything you need, NaCl doesn't have a very large API, so this is probably everything.

## Do I need performance or code size?

NaCl was written with performance in mind, unfortunately a lot of that is lost when you compile it to JavaScript. However, Chloride still has the fastest _JavaScript_ elliptic curve signature that I am aware of (and asymmetric crypto is much slower than symmetric, so this is always the weak point).

If you are only doing a symmetric ciphers (`crypto_box`) or a signature or two, then performance is probably not a problem. If you are verifying _many_ signatures, performance _may_ be a problem. Bear in mind that an asymetric operation (`sign`, `verify`, `scalarmult`, `keygen`) is usually 50 times slower than a symmetric operation, for instance a hash.

See [sodiumperf](https://github.com/dominictarr/sodiumperf) performance comparisons.

To run Chloride in performance mode, load it like this:

```js
const chloride = require('chloride')
```

To run in low size mode:

```js
const chloride = require('chloride/small')
```

This only applies to enviroments that only support JavaScript.  If you are running this on the server and could compile libsodium, then you have the same fast crypto either way.

## License

MIT

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