2018-06-25 08:25:12 +02:00
|
|
|
const createHash = require('create-hash')
|
2014-04-08 14:13:03 +02:00
|
|
|
|
2018-12-26 08:13:43 +01:00
|
|
|
export function ripemd160 (buffer: Buffer): Buffer {
|
2015-03-17 02:31:53 +01:00
|
|
|
return createHash('rmd160').update(buffer).digest()
|
2014-06-26 11:26:21 +02:00
|
|
|
}
|
|
|
|
|
2018-12-26 08:13:43 +01:00
|
|
|
export function sha1 (buffer: Buffer): Buffer {
|
2015-03-17 02:31:53 +01:00
|
|
|
return createHash('sha1').update(buffer).digest()
|
2014-04-08 14:13:03 +02:00
|
|
|
}
|
|
|
|
|
2018-12-26 08:13:43 +01:00
|
|
|
export function sha256 (buffer: Buffer): Buffer {
|
2015-03-17 02:31:53 +01:00
|
|
|
return createHash('sha256').update(buffer).digest()
|
2014-04-08 14:13:03 +02:00
|
|
|
}
|
|
|
|
|
2018-12-26 08:13:43 +01:00
|
|
|
export function hash160 (buffer: Buffer): Buffer {
|
2016-09-28 00:44:21 +02:00
|
|
|
return ripemd160(sha256(buffer))
|
|
|
|
}
|
|
|
|
|
2018-12-26 08:13:43 +01:00
|
|
|
export function hash256 (buffer: Buffer): Buffer {
|
2016-09-28 00:44:21 +02:00
|
|
|
return sha256(sha256(buffer))
|
|
|
|
}
|