Package Exports
- @valtech-commerce/tweetnacl
- @valtech-commerce/tweetnacl/dist/kafe.js
- @valtech-commerce/tweetnacl/dist/node.js
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 (@valtech-commerce/tweetnacl) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
@valtech-commerce/tweetnacl
TweetNaCl wrapper
Wrap TweetNaCl functionalities
Install
$ npm install @valtech-commerce/tweetnaclUsage
// Node.js
const tweetnacl = require('@valtech-commerce/tweetnacl');
// Browser
// Load TweetNaCl libraries
// - /node_modules/tweetnacl/nacl-fast.js
// - /node_modules/tweetnacl-util/nacl-util.js
const { tweetnacl } = window.kafe;
// Lock the box
const { box, key } = tweetnacl.secretbox.lock('Dirty little secret');
console.log({ box, key });
// Outputs:
// {
// box: "ThyOjmYtUvWSGne8lxXK7sJWGc/oigJ+I51pauSN/xTLpoufdAVNcCCQmtnwHlsu/hD7xnNZr7snkW4="
// key: "ri4kzZ4V1pMGhGLqeqQayT3m2yT8FY79e1snqp2UAFg="
// }
// Unlock the box
const message = tweetnacl.secretbox.unlock(box, key);
console.log(message);
// Outputs:
// Dirty little secretAPI
secretbox.lock(message)
Wraps nacl.secretbox with autogeneration of nonce and key
Returns an Object with String properties of box and key
message
Required
Type: String
Message to lock
secretbox.unlock(box, key)
Wraps nacl.secretbox.open with autoextraction of nonce from box
Returns a String message
box
Required
Type: String
Box containing encrypted message and nonce
key
Required
Type: String
Key to unlock box
License
MIT © Valtech Canada inc.