You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

33 lines
678 B

const createHash = require('create-hash');
export function ripemd160(buffer: Buffer): Buffer {
try {
return createHash('rmd160')
.update(buffer)
.digest();
} catch (err) {
return createHash('ripemd160')
.update(buffer)
.digest();
}
}
export function sha1(buffer: Buffer): Buffer {
return createHash('sha1')
.update(buffer)
.digest();
}
export function sha256(buffer: Buffer): Buffer {
return createHash('sha256')
.update(buffer)
.digest();
}
export function hash160(buffer: Buffer): Buffer {
return ripemd160(sha256(buffer));
}
export function hash256(buffer: Buffer): Buffer {
return sha256(sha256(buffer));
}