mirror of
https://github.com/fluencelabs/js-libp2p-crypto
synced 2025-03-15 10:11:02 +00:00
* fix: replace node buffers with uint8arrays All usage of node buffers have been replaced with uint8arrays. BREAKING CHANGES: - Where node Buffers were returned, now Uint8Arrays are * chore: remove commented code
24 lines
668 B
JavaScript
24 lines
668 B
JavaScript
/* eslint max-nested-callbacks: ["error", 8] */
|
|
/* eslint-env mocha */
|
|
'use strict'
|
|
|
|
const chai = require('chai')
|
|
const dirtyChai = require('dirty-chai')
|
|
const expect = chai.expect
|
|
chai.use(dirtyChai)
|
|
const uint8ArrayFromString = require('uint8arrays/from-string')
|
|
|
|
const crypto = require('../../src')
|
|
|
|
const hashes = ['SHA1', 'SHA256', 'SHA512']
|
|
|
|
describe('HMAC', () => {
|
|
hashes.forEach((hash) => {
|
|
it(`${hash} - sign and verify`, async () => {
|
|
const hmac = await crypto.hmac.create(hash, uint8ArrayFromString('secret'))
|
|
const sig = await hmac.digest(uint8ArrayFromString('hello world'))
|
|
expect(sig).to.have.length(hmac.length)
|
|
})
|
|
})
|
|
})
|