fix: consistent buffer usage (#56)

* fix: consistent buffer usage

Closes #49

* more fixes for node 4
This commit is contained in:
Friedel Ziegelmayer
2017-01-16 05:17:50 +01:00
committed by David Dias
parent c45bdf602e
commit 1a2d468369
18 changed files with 65 additions and 42 deletions

View File

@ -2,7 +2,9 @@
/* 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']
@ -10,10 +12,10 @@ const hashes = ['SHA1', 'SHA256', 'SHA512']
describe('HMAC', () => {
hashes.forEach((hash) => {
it(`${hash} - sign and verify`, (done) => {
crypto.hmac.create(hash, new Buffer('secret'), (err, hmac) => {
crypto.hmac.create(hash, Buffer.from('secret'), (err, hmac) => {
expect(err).to.not.exist
hmac.digest(new Buffer('hello world'), (err, sig) => {
hmac.digest(Buffer.from('hello world'), (err, sig) => {
expect(err).to.not.exist
expect(sig).to.have.length(hmac.length)
done()