mirror of
https://github.com/fluencelabs/js-libp2p-crypto
synced 2025-03-16 02:41:02 +00:00
* fix: add buffer, cleanup, reduce size - add buffer related to https://github.com/ipfs/js-ipfs/issues/2924 - remove unnecessary eslint ignore - remove tweelnacl and use node-forge - remove browserify-aes and use node-forge - use multibase to encode b58 - require only sha256 from multihashing - reduce bundle size after all the deps here https://github.com/ipfs/js-ipfs/issues/2924 are merged libp2p-crypto will be able to be bundle with `node: false` 🎉 * fix: reduce bundle size * fix: use new secp * fix: bundle size * chore: update secp Co-Authored-By: Jacob Heun <jacobheun@gmail.com> Co-authored-by: Jacob Heun <jacobheun@gmail.com>
23 lines
622 B
JavaScript
23 lines
622 B
JavaScript
/* eslint max-nested-callbacks: ["error", 8] */
|
|
/* eslint-env mocha */
|
|
'use strict'
|
|
const { Buffer } = require('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`, 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)
|
|
})
|
|
})
|
|
})
|