Natrium
libsodium node.js bindings
Browser version - link
Install
npm i --save natrium
Requirements
- Build tools
- GNU C++
- Make
- Node.js/io.js v3.0.0 or newer
- Npm 3.2.2 or newer
- Libraries
- V8
- Sodium
Building the native module tested only on Linux
Usage
Import / Require
;// ORvar natrium = default;
Await the promises!!
The examples below demonstrate the usage with promises. With ecmascript 7, you can await the promises to get the result as in synchronous code. This works for all the code below. To use the await keyword, it must be contained inside an async function.
// Generate a random bufferlet random = await natrium;console;// <Buffer fa 17 e8 b5 bb e5 72 6b 9d 41 ec 3a 91 97 07 f4>
Random buffers
// Generate a random buffernatrium;// <Buffer fa 17 e8 b5 bb e5 72 6b 9d 41 ec 3a 91 97 07 f4> // Generate a random buffer with the correct size for a signature seednatrium;// <Buffer dc 0e 74 90 54 43 10 55 ea 21 96 6c a5 9b 16 59 71 e5 77 e2 ca 04 02 af 05 ed 98 93 29 32 d2 a1>
Encrypt & Decrypt
natrium;
Secret key // Encrypt & Decrypt
natrium;
Sign & Verify
natrium;