ethers.js/utils/sha2.js

24 lines
459 B
JavaScript
Raw Normal View History

2017-02-24 22:57:46 +03:00
'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,
}