mirror of
https://github.com/wu736139669/Monkey-Test.git
synced 2026-08-07 06:37:16 +00:00
25 lines
549 B
JavaScript
25 lines
549 B
JavaScript
|
|
var test = require('tape')
|
|
|
|
var algorithms = require('../').getHashes()
|
|
var vectors = require('hash-test-vectors/hmac')
|
|
var createHmac = require('../create-hmac')
|
|
|
|
algorithms.forEach(function (alg) {
|
|
|
|
test('hmac('+alg+')', function (t) {
|
|
vectors.forEach(function (input, i) {
|
|
var output = createHmac(alg, new Buffer(input.key, 'hex'))
|
|
.update(input.data, 'hex').digest()
|
|
|
|
output = input.truncate ? output.slice(0, input.truncate) : output
|
|
t.equal(output.toString('hex'), input[alg])
|
|
})
|
|
t.end()
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|