ethers.js/utils/hmac.js

23 lines
502 B
JavaScript
Raw Normal View History

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
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); }
return new hash.hmac(hash.sha256, 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); }
return new hash.hmac(hash.sha512, key);
2017-02-24 22:57:46 +03:00
}
2017-02-27 08:05:39 +03:00
module.exports = {
createSha256Hmac: createSha256Hmac,
createSha512Hmac: createSha512Hmac,
};