# sodium-javascript

> WIP - a pure javascript version of sodium-native

Latest version **0.8.0** (published 2022-01-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install sodium-javascript
pnpm add sodium-javascript
yarn add sodium-javascript
bun add sodium-javascript
```

## 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.8.0 |
| Published | 2022-01-14 |
| First published | 2017-01-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 7 |
| Unpacked size | 84.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 93 |
| Maintainers | mafintosh, emilbayes, chm-diederichs |

## Links

- npm: https://www.npmjs.com/package/sodium-javascript
- Repository: https://github.com/sodium-friends/sodium-javascript
- Homepage: https://github.com/sodium-friends/sodium-javascript#readme
- Issues: https://github.com/sodium-friends/sodium-javascript/issues
- npm.io page: https://npm.io/package/sodium-javascript

## Dependencies (7)

- [blake2b](https://npm.io/package/blake2b.md) ^2.1.1
- [xsalsa20](https://npm.io/package/xsalsa20.md) ^1.0.0
- [siphash24](https://npm.io/package/siphash24.md) ^1.0.1
- [nanoassert](https://npm.io/package/nanoassert.md) ^2.0.0
- [sha256-universal](https://npm.io/package/sha256-universal.md) ^1.1.0
- [sha512-universal](https://npm.io/package/sha512-universal.md) ^1.1.0
- [chacha20-universal](https://npm.io/package/chacha20-universal.md) ^1.0.4

## Recent versions

- 0.8.0 (latest) — 2022-01-14
- 0.7.4 — 2021-11-05
- 0.7.3 — 2020-11-13
- 0.7.2 — 2020-11-12
- 0.7.1 — 2020-09-22
- 0.7.0 — 2020-09-22
- 0.6.3 — 2020-09-17
- 0.6.2 — 2020-08-12
- 0.6.1 — 2020-06-24
- 0.6.0 — 2020-06-18
- 0.5.6 — 2020-03-04
- 0.5.5 — 2018-03-19
- 0.5.4 — 2017-11-19
- 0.5.3 — 2017-11-17
- 0.5.2 — 2017-11-03
- … 8 more at https://npm.io/package/sodium-javascript/versions

## README

# `sodium-javascript`

[![Build Status](https://travis-ci.org/sodium-friends/sodium-javascript.svg?branch=master)](https://travis-ci.org/sodium-friends/sodium-javascript)

> WIP - a pure javascript version of [sodium-native](https://github.com/sodium-friends/sodium-native).
Based on tweetnacl

## Usage

``` js
const sodium = require('sodium-javascript')

const key = Buffer.alloc(sodium.crypto_secretbox_KEYBYTES)
const nonce = Buffer.alloc(sodium.crypto_secretbox_NONCEBYTES)

sodium.randombytes_buf(key)
sodium.randombytes_buf(nonce)

const message = Buffer.from('Hello, World!')
const cipher = Buffer.alloc(message.length + sodium.crypto_secretbox_MACBYTES)

sodium.crypto_secretbox_easy(cipher, message, nonce, key)

console.log('Encrypted:', cipher)

const plainText = Buffer.alloc(cipher.length - sodium.crypto_secretbox_MACBYTES)

sodium.crypto_secretbox_open_easy(plainText, cipher, nonce, key)

console.log('Plaintext:', plainText.toString())
```

## API

See [sodium-native](https://github.com/sodium-friends/sodium-native).
This is a work in progress so not all functions are implemented yet.

This module is organised into individual submodules which can be required
independently for smaller bundles in the browser. To leverage automatic
switching between `sodium-javascript` and `sodium-native`, see
[`sodium-universal`](https://github.com/sodium-friends/sodium-universal).

## Install

```
npm install sodium-javascript
```

## License

[MIT](LICENSE)

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