@geut/sodium-javascript-plus

0.0.6 • Public • Published

sodium-javascript-plus

Build Status experimental JavaScript Style Guide standard-readme compliant

Experimental 🔬 sodium-javascript with support for xchacha20 and kx

Install

$ npm install @geut/sodium-javascript-plus

Usage

const message = Buffer.from('some secret message')
const ad = Buffer.from('50515253c0c1c2c3c4c5c6c7', 'hex')
const nonce = Buffer.from('404142434445464748494a4b4c4d4e4f5051525354555657', 'hex')
const key = Buffer.from('808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f', 'hex')
const cipher = Buffer.alloc(message.length + sodium.crypto_aead_xchacha20poly1305_ietf_ABYTES)

sodium.crypto_aead_xchacha20poly1305_ietf_encrypt(
  cipher,
  message,
  ad,
  null,
  nonce,
  key
)

const decrypted = Buffer.alloc(message.length)

sodium.crypto_aead_xchacha20poly1305_ietf_decrypt(
  decrypted,
  null,
  cipher,
  ad,
  nonce,
  key
)

console.log(message.equals(decrypted), 'same message')

You can extend your sodium instance

const extend = require('@geut/sodium-javascript-plus/extend')
const sodium = extend(require('sodium-javascript'))

// ...

Issues

🐛 If you found an issue we encourage you to report it on github. Please specify your OS and the actions to reproduce it.

Contributing

👥 Ideas and contributions to the project are welcome. You must follow this guideline.

License

MIT © A GEUT project

Readme

Keywords

Package Sidebar

Install

npm i @geut/sodium-javascript-plus

Weekly Downloads

8

Version

0.0.6

License

MIT

Unpacked Size

41.8 kB

Total Files

23

Last publish

Collaborators

  • geutuser
  • the-real-dk
  • tinchoz49
  • estebanprimost