mirror of
https://github.com/fluencelabs/js-libp2p-crypto
synced 2025-06-26 11:41:43 +00:00
fix: consistent buffer usage (#56)
* fix: consistent buffer usage Closes #49 * more fixes for node 4
This commit is contained in:
committed by
David Dias
parent
c45bdf602e
commit
1a2d468369
@ -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()
|
||||
|
Reference in New Issue
Block a user