sodium-javascript

WIP - a pure javascript version of sodium-native

MIT 23 个版本
安装
npm install sodium-javascript
yarn add sodium-javascript
pnpm add sodium-javascript
bun add sodium-javascript
README

sodium-javascript

Build Status

WIP - a pure javascript version of sodium-native. Based on tweetnacl

Usage

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

Install

npm install sodium-javascript

License

MIT

版本列表
0.8.0 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
0.5.1 2017-07-13
0.5.0 2017-06-28
0.3.1 2017-06-12
0.3.0 2017-06-12
0.2.0 2017-06-07
0.1.0 2017-06-06
0.0.1 2017-02-12
0.0.0 2017-01-24