2014-04-08 14:13:03 +02:00
|
|
|
var crypto = require('crypto')
|
|
|
|
|
2015-02-23 00:36:57 +01:00
|
|
|
function hash160 (buffer) {
|
2014-06-26 11:26:21 +02:00
|
|
|
return ripemd160(sha256(buffer))
|
2014-04-08 14:13:03 +02:00
|
|
|
}
|
|
|
|
|
2015-02-23 00:36:57 +01:00
|
|
|
function hash256 (buffer) {
|
2014-04-08 14:13:03 +02:00
|
|
|
return sha256(sha256(buffer))
|
|
|
|
}
|
|
|
|
|
2015-02-23 00:36:57 +01:00
|
|
|
function ripemd160 (buffer) {
|
2014-06-26 11:26:54 +02:00
|
|
|
return crypto.createHash('rmd160').update(buffer).digest()
|
2014-06-26 11:26:21 +02:00
|
|
|
}
|
|
|
|
|
2015-02-23 00:36:57 +01:00
|
|
|
function sha1 (buffer) {
|
2014-04-08 14:13:03 +02:00
|
|
|
return crypto.createHash('sha1').update(buffer).digest()
|
|
|
|
}
|
|
|
|
|
2015-02-23 00:36:57 +01:00
|
|
|
function sha256 (buffer) {
|
2014-04-08 14:13:03 +02:00
|
|
|
return crypto.createHash('sha256').update(buffer).digest()
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
hash160: hash160,
|
2014-05-10 01:55:55 +02:00
|
|
|
hash256: hash256,
|
2014-09-20 03:20:55 +02:00
|
|
|
ripemd160: ripemd160,
|
|
|
|
sha1: sha1,
|
|
|
|
sha256: sha256
|
2014-03-08 06:02:40 +01:00
|
|
|
}
|