refactor: the whole thing (#102)

This commit is contained in:
David Dias
2017-07-22 10:57:27 -07:00
committed by GitHub
parent c2c6fde394
commit 2f8e234044
43 changed files with 769 additions and 976 deletions

21
src/hmac/index.js Normal file
View File

@ -0,0 +1,21 @@
'use strict'
const crypto = require('crypto')
const lengths = require('./lengths')
exports.create = function (hash, secret, callback) {
const res = {
digest (data, cb) {
const hmac = crypto.createHmac(hash.toLowerCase(), secret)
hmac.update(data)
setImmediate(() => {
cb(null, hmac.digest())
})
},
length: lengths[hash]
}
callback(null, res)
}