首次放到 git
This commit is contained in:
24
utils/hmac.js
Normal file
24
utils/hmac.js
Normal 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,
|
||||
};
|
||||
Reference in New Issue
Block a user