bitcoinjs-lib/src/crypto.js

30 lines
549 B
JavaScript
Raw Normal View History

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))
}
2015-02-23 00:36:57 +01:00
function hash256 (buffer) {
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) {
return crypto.createHash('sha1').update(buffer).digest()
}
2015-02-23 00:36:57 +01:00
function sha256 (buffer) {
return crypto.createHash('sha256').update(buffer).digest()
}
module.exports = {
hash160: hash160,
hash256: hash256,
2014-09-20 03:20:55 +02:00
ripemd160: ripemd160,
sha1: sha1,
sha256: sha256
2014-03-08 06:02:40 +01:00
}