首次放到 git
This commit is contained in:
23
utils/sha2.js
Normal file
23
utils/sha2.js
Normal file
@@ -0,0 +1,23 @@
|
||||
'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,
|
||||
}
|
||||
Reference in New Issue
Block a user