mirror of
https://github.com/fluencelabs/js-libp2p-crypto
synced 2025-06-26 15:11:50 +00:00
feat: use webcrypto in favor of node-forge
BREAKING CHANGE: generateKeyPair is now async
This commit is contained in:
24
test/hmac.spec.js
Normal file
24
test/hmac.spec.js
Normal file
@ -0,0 +1,24 @@
|
||||
/* eslint max-nested-callbacks: ["error", 8] */
|
||||
/* eslint-env mocha */
|
||||
'use strict'
|
||||
|
||||
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, new Buffer('secret'), (err, hmac) => {
|
||||
expect(err).to.not.exist
|
||||
|
||||
hmac.digest(new Buffer('hello world'), (err, sig) => {
|
||||
expect(err).to.not.exist
|
||||
expect(sig).to.have.length(hmac.length)
|
||||
done()
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
Reference in New Issue
Block a user