首次放到 git

This commit is contained in:
Luk.Lu
2018-10-09 23:03:05 +08:00
commit 16cca302b7
37 changed files with 4203 additions and 0 deletions

24
utils/hmac.js Normal file
View File

@@ -0,0 +1,24 @@
'use strict';
var hash = require('hash.js');
var sha2 = require('./sha2.js');
var convert = require('./convert.js');
// @TODO: Make this use create-hmac in node
function createSha256Hmac(key) {
if (!key.buffer) { key = convert.arrayify(key); }
return new hash.hmac(sha2.createSha256, key);
}
function createSha512Hmac(key) {
if (!key.buffer) { key = convert.arrayify(key); }
return new hash.hmac(sha2.createSha512, key);
}
module.exports = {
createSha256Hmac: createSha256Hmac,
createSha512Hmac: createSha512Hmac,
};