orwelldb
Version:
Library, wich helps syncronize blockchain and any database use datascript protocol to write operations (can be wroten in blockchain transactions hex like scriptSig or scriptPubKey)
18 lines (17 loc) • 579 B
JavaScript
var hash = require('hash.js');
var crypto = require('crypto');
module.exports = {
sha256: function (message, output) {
if (!output)
output = '';
return crypto.createHash('sha256').update(message).digest(output);
},
ripemd160: function (message, output) {
if (!output)
output = '';
return hash.ripemd160().update(message).digest(output)
},
generateAddressHash: function (pubHex) {
return module.exports.ripemd160(module.exports.sha256(new Buffer(pubHex, 'hex')), 'hex');
}
}