24 lines
459 B
JavaScript
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,
|
|
}
|