开发者社区> 镜像站> NPM> sodium-javascript
sodium-javascript
WIP - a pure javascript version of sodium-native
Last updated 21 days ago by mafintosh .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install sodium-javascript 
SYNC missed versions from official npm registry.

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

Current Tags

  • 0.7.3                                ...           latest (21 days ago)

21 Versions

  • 0.7.3                                ...           21 days ago
  • 0.7.2                                ...           22 days ago
  • 0.7.1                                ...           2 months ago
  • 0.7.0                                ...           2 months ago
  • 0.6.3                                ...           3 months ago
  • 0.6.2                                ...           4 months ago
  • 0.6.1                                ...           5 months ago
  • 0.6.0                                ...           6 months ago
  • 0.5.6                                ...           9 months ago
  • 0.5.5                                ...           3 years ago
  • 0.5.4                                ...           3 years ago
  • 0.5.3                                ...           3 years ago
  • 0.5.2                                ...           3 years ago
  • 0.5.1                                ...           3 years ago
  • 0.5.0                                ...           3 years ago
  • 0.3.1                                ...           3 years ago
  • 0.3.0                                ...           3 years ago
  • 0.2.0                                ...           3 years ago
  • 0.1.0                                ...           3 years ago
  • 0.0.1                                ...           4 years ago
  • 0.0.0                                ...           4 years ago
Downloads
Today 21
This Week 31
This Month 29
Last Day 0
Last Week 16
Last Month 402
Dependencies (7)
Dev Dependencies (4)