mirror of
https://github.com/fluencelabs/js-libp2p-crypto
synced 2025-06-23 21:41:50 +00:00
feat: refactor to use async/await (#131)
BREAKING CHANGE: API refactored to use async/await feat: WIP use async await fix: passing tests chore: update travis node.js versions fix: skip ursa optional tests on windows fix: benchmarks docs: update docs fix: remove broken and intested private key decrypt chore: update deps
This commit is contained in:
@ -13,16 +13,10 @@ 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()
|
||||
})
|
||||
})
|
||||
it(`${hash} - sign and verify`, async () => {
|
||||
const hmac = await crypto.hmac.create(hash, Buffer.from('secret'))
|
||||
const sig = await hmac.digest(Buffer.from('hello world'))
|
||||
expect(sig).to.have.length(hmac.length)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
Reference in New Issue
Block a user