js-libp2p-crypto/test/hmac.spec.js
Friedel Ziegelmayer 1a2d468369 fix: consistent buffer usage (#56)
* fix: consistent buffer usage

Closes #49

* more fixes for node 4
2017-01-16 05:17:50 +01:00

27 lines
656 B
JavaScript

/* eslint max-nested-callbacks: ["error", 8] */
/* eslint-env mocha */
'use strict'
const Buffer = require('safe-buffer').Buffer
const expect = require('chai').expect
const crypto = require('../src')
const hashes = ['SHA1', 'SHA256', 'SHA512']
describe('HMAC', () => {
hashes.forEach((hash) => {
it(`${hash} - sign and verify`, (done) => {
crypto.hmac.create(hash, Buffer.from('secret'), (err, hmac) => {
expect(err).to.not.exist
hmac.digest(Buffer.from('hello world'), (err, sig) => {
expect(err).to.not.exist
expect(sig).to.have.length(hmac.length)
done()
})
})
})
})
})