JSPM

@geut/sodium-javascript-plus

0.0.6
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q42690F
  • License MIT

sodium-javascript with xchacha20 and kx support

Package Exports

  • @geut/sodium-javascript-plus

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@geut/sodium-javascript-plus) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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