Fix issue with crypto library browser ripemd160 support.
This commit is contained in:
parent
c6593f1a70
commit
07a02ec86b
|
@ -1,6 +1,5 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var hashjs = require('hash.js');
|
|
||||||
var sha512 = require('sha512');
|
var sha512 = require('sha512');
|
||||||
var crypto = require('crypto');
|
var crypto = require('crypto');
|
||||||
var BufferUtil = require('../util/buffer');
|
var BufferUtil = require('../util/buffer');
|
||||||
|
@ -29,19 +28,9 @@ Hash.sha256sha256 = function(buf) {
|
||||||
|
|
||||||
Hash.ripemd160 = function(buf) {
|
Hash.ripemd160 = function(buf) {
|
||||||
$.checkArgument(BufferUtil.isBuffer(buf));
|
$.checkArgument(BufferUtil.isBuffer(buf));
|
||||||
return crypto.createHash('ripemd160').update(buf).digest();
|
return crypto.createHash('rmd160').update(buf).digest();
|
||||||
};
|
};
|
||||||
|
|
||||||
// Node.js crypto ripemd160 hashes are not supported in a browser
|
|
||||||
// We'll replace with a (slower) version that does.
|
|
||||||
if (process.browser) {
|
|
||||||
Hash.ripemd160 = function(buf) {
|
|
||||||
$.checkArgument(BufferUtil.isBuffer(buf));
|
|
||||||
var hash = (new hashjs.ripemd160()).update(buf).digest();
|
|
||||||
return new Buffer(hash);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
Hash.sha256ripemd160 = function(buf) {
|
Hash.sha256ripemd160 = function(buf) {
|
||||||
$.checkArgument(BufferUtil.isBuffer(buf));
|
$.checkArgument(BufferUtil.isBuffer(buf));
|
||||||
return Hash.ripemd160(Hash.sha256(buf));
|
return Hash.ripemd160(Hash.sha256(buf));
|
||||||
|
|
Loading…
Reference in New Issue