@geut/sodium-javascript-plus
v0.0.6
Published
sodium-javascript with xchacha20 and kx support
Downloads
39
Readme
sodium-javascript-plus
Experimental :microscope: 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
:bug: If you found an issue we encourage you to report it on github. Please specify your OS and the actions to reproduce it.
Contributing
:busts_in_silhouette: Ideas and contributions to the project are welcome. You must follow this guideline.
License
MIT © A GEUT project