ethers.js/utils/sha2.js
2017-02-24 14:57:46 -05:00

24 lines
459 B
JavaScript

'use strict';
var hash = require('hash.js');
var convert = require('./convert.js');
function sha256(data) {
data = convert.arrayify(data);
return '0x' + (hash.sha256().update(data).digest('hex'));
}
function sha512(data) {
data = convert.arrayify(data);
return '0x' + (hash.sha512().update(data).digest('hex'));
}
module.exports = {
sha256: sha256,
sha512: sha512,
createSha256: hash.sha256,
createSha512: hash.sha512,
}