2017-02-24 22:57:46 +03:00
|
|
|
'use strict';
|
|
|
|
|
2017-02-27 08:05:39 +03:00
|
|
|
var hash = require('hash.js');
|
2017-02-24 22:57:46 +03:00
|
|
|
|
2017-02-28 01:35:23 +03:00
|
|
|
var sha2 = require('./sha2.js');
|
|
|
|
|
2017-02-24 22:57:46 +03:00
|
|
|
var convert = require('./convert.js');
|
|
|
|
|
2017-02-27 08:05:39 +03:00
|
|
|
// @TODO: Make this use create-hmac in node
|
2017-02-24 22:57:46 +03:00
|
|
|
|
2017-02-27 08:05:39 +03:00
|
|
|
function createSha256Hmac(key) {
|
|
|
|
if (!key.buffer) { key = convert.arrayify(key); }
|
2017-02-28 01:35:23 +03:00
|
|
|
return new hash.hmac(sha2.createSha256, key);
|
2017-02-24 22:57:46 +03:00
|
|
|
}
|
|
|
|
|
2017-02-27 08:05:39 +03:00
|
|
|
function createSha512Hmac(key) {
|
|
|
|
if (!key.buffer) { key = convert.arrayify(key); }
|
2017-02-28 01:35:23 +03:00
|
|
|
return new hash.hmac(sha2.createSha512, key);
|
2017-02-24 22:57:46 +03:00
|
|
|
}
|
|
|
|
|
2017-02-27 08:05:39 +03:00
|
|
|
module.exports = {
|
|
|
|
createSha256Hmac: createSha256Hmac,
|
|
|
|
createSha512Hmac: createSha512Hmac,
|
|
|
|
};
|