mirror of
https://github.com/fluencelabs/js-libp2p-crypto
synced 2025-06-27 19:41:38 +00:00
refactor: the whole thing (#102)
This commit is contained in:
29
test/hmac/hmac.spec.js
Normal file
29
test/hmac/hmac.spec.js
Normal file
@ -0,0 +1,29 @@
|
||||
/* eslint max-nested-callbacks: ["error", 8] */
|
||||
/* eslint-env mocha */
|
||||
'use strict'
|
||||
|
||||
const Buffer = require('safe-buffer').Buffer
|
||||
const chai = require('chai')
|
||||
const dirtyChai = require('dirty-chai')
|
||||
const expect = chai.expect
|
||||
chai.use(dirtyChai)
|
||||
|
||||
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()
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
Reference in New Issue
Block a user