1.0.1 • Published 9 years ago

hmac v1.0.1

Weekly downloads
310
License
MIT
Repository
github
Last release
9 years ago

hmac

pure js hmac that can be used with any create hash function.

example

var Blake2s = require('blake2s')
function createBlake2s () {
  return new Blake2s()
}
var createHmac = require('hmac')
  .bind(null, createBlake2s, 64)

var hmac = createHmac('key 123')

var mac = hmac.update('foo', 'utf8').digest('hex')

tested with sha family algorithms against node's crypto lib, and produces correct hashes.

api: createHmac(createHash, len, key)

where createHash is a function that returns {update(), digest()} object and len is either 128 or 64 (sha1, sha224, sha256 use 64, and sha384, sha512 use 128)

key is the key (secret) to the hmac.

see also crypto.createHmac()

License

MIT