avon

node bindings for the blake2 cryptographic hash

avon

Node bindings for the blake2 cryptographic hash function.

Blake2 provides four different hashing functions:

  • blake2b, blake2bp: 64-bit architectures, single & multicore variations
  • blake2s, blake2sp: 32-bit and under architectures, single & multicore variations

All four algorithms are different & will produce different sums. Choose the one that's appropriate for your use.

All four functions take an optional callback. If no callback is provided, they return promises. Use the flow control method you prefer! The calculated hash is a node Buffer.

var Avon = require('avon');
var assert = require('assert');
 
var buf = new Buffer('this is some input');
 
Avon.blake2b(buf)
.then(function(hash)
{
    assert(hash instanceof Buffer);
    console.log(hash.toString('hex'));
}, function(err)
{
    console.error('noooooo! ' + err.message);
}).done();
 
Avon.blake2bp(buf, function(errbuffer)
{
    if (err) console.error('noooo!');
    else console.log(buffer.toString('hex'))
})

The functions can also take a filename input:

Avon.blake2b('my_file.dat')
.then(function(hash)
{
    assert(hash instanceof Buffer);
    console.log(hash.toString('hex'));
}, function(err)
{
    console.error('noooooo! ' + err.message);
}).done();
 
Avon.blake2bp('my_file.dat', function(errbuffer)
{
    if (err) console.error('noooo!');
    else console.log(buffer.toString('hex'))
})
  • See about stream input.
  • BREAK THE API and provide file-specific functions so we can handle strings.
  • Refactor blake2.cpp to simplify.

V8 bindings made considerably easier thanks to rvagg's NAN.

ICS.