JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 29308
  • Score
    100M100P100Q160762F
  • License ISC

All four BLAKE2 variants (blake2b, blake2bp, blake2s, blake2sp) for io.js with stream support

Package Exports

  • blake2

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 (blake2) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

node-blake2

Why BLAKE2 for hashing? Because "BLAKE2 outperforms MD5, SHA-1, SHA-2, and SHA-3 on recent Intel CPUs" and has "no known security issues, whereas SHA-1, MD5, and SHA-512 are susceptible to length-extension". https://blake2.net/

node-blake2 provides a stream-compatible blake2b, blake2bp, blake2s, and blake2sp Hash and Hmac for io.js.

node-blake2 was tested to work on - Ubuntu 14.04 (g++ 4.8.2) - Ubuntu 15.04 (g++ 4.9.2) - Windows 8.1 x64 (VS2013) - OS X 10.10 (Apple LLVM 6.1.0)

Install

On Windows, first install Python 2.7.9 so that node-gyp works.

Run:

npm install blake2 --save

or to install from the GitHub repo:

git clone https://github.com/ludios/node-blake2
cd node-blake2
npm install --verbose

Examples

blake2.createHash and blake2.createHmac work just like node's crypto.createHash and crypto.createHmac, except:

  • blake2.create{Hash,Hmac} support only algorithms blake2b, blake2bp, blake2s, and blake2sp.
  • Keys passed to blake2.createHmac(algo, key) must be a Buffer.
  • Data passed to .update on blake2.{Hash,Hmac} must be a Buffer.

Unkeyed BLAKE2b:

var blake2 = require('blake2');
var h = blake2.createHash('blake2b');
h.update(new Buffer("test"));
console.log(h.digest("hex"));

Keyed BLAKE2b:

var blake2 = require('blake2');
var h = blake2.createHmac('blake2b', new Buffer('key - up to 64 bytes for blake2b, 32 for blake2s'));
h.update(new Buffer("test"));
console.log(h.digest("hex"));

With streams:

This should work exactly like it does with crypto.Hash. See b2sum.js.

Known issues

  • I don't recommend using the multithreaded algorithms blake2bp and blake2sp because
  • On Windows, node-blake2 requires AVX instructions due to some SSE2 build problems. This shouldn't be too hard to fix.