sodium-javascript-plus
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
Contributing
License
MIT © A GEUT project