$ cnpm install hmac-blake2b
hmac-blake2bHMAC based on BLAKE2b
Even though BLAKE2b is designed to also work as a MAC, specifications like Noise call for a HMAC.
var sodium = require('sodium-universal')
var hmac = require('hmac-blake2b')
var mac = Buffer.alloc(hmac.BYTES)
var key = Buffer.alloc(hmac.KEYBYTES)
sodium.randombytes_buf(key)
var data = Buffer.from('some data')
hmac(mac, data, key)
hmac.BYTESSize of the output MAC in bytes
hmac.KEYBYTESRFC2104 recommended size of the key in bytes.
hmac(out, data, key)Computes a HMAC from data with key and writes it into out.
out must be a Buffer or Uint8Array of length hmac.BYTESdata must be a Buffer, Uint8Array or Array of Buffers or
Uint8Arrays.key must be a Buffer or Uint8Array. Per the HMAC spec key can be as
small as 1 byte, in which case it is right-padded with NUL bytes, or any
size larger than hmac.KEYBYTES in which case it is hashed down to fit. The
recommended size by the spec is hmac.KEYBYTESnpm install hmac-blake2b
Copyright 2013 - present © cnpmjs.org | Home |