crypto: add RIPEMD160 tests

This commit is contained in:
Daniel Cousens 2014-06-26 19:26:21 +10:00
parent 0198477c6d
commit 9d2784a441
3 changed files with 39 additions and 28 deletions

View file

@ -5,18 +5,20 @@ var crypto = require('crypto')
var convert = require('./convert')
function hash160(buffer) {
var step1 = sha256(buffer)
var step2a = convert.bufferToWordArray(step1)
var step2b = CryptoJS.RIPEMD160(step2a)
return convert.wordArrayToBuffer(step2b)
return ripemd160(sha256(buffer))
}
function hash256(buffer) {
return sha256(sha256(buffer))
}
function ripemd160(buffer) {
var array = convert.bufferToWordArray(buffer)
var result = CryptoJS.RIPEMD160(array)
return convert.wordArrayToBuffer(result)
}
function sha1(buffer) {
return crypto.createHash('sha1').update(buffer).digest()
}
@ -43,6 +45,7 @@ function HmacSHA512(data, secret) {
}
module.exports = {
ripemd160: ripemd160,
sha1: sha1,
sha256: sha256,
hash160: hash160,