Skip to content
This repository was archived by the owner on Jan 25, 2024. It is now read-only.

Commit 0c3f75b

Browse files
committed
BG-10188 use createHash(ripemd160) if rmd160 is not supported (e.g. in electron)
1 parent 0e48e07 commit 0c3f75b

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/crypto.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
var createHash = require('create-hash')
2+
var crypto = require('crypto')
23

34
function ripemd160 (buffer) {
4-
return createHash('rmd160').update(buffer).digest()
5+
var hash = 'rmd160'
6+
var supportedHashes = crypto.getHashes()
7+
// some environments (electron) only support the long alias
8+
if (supportedHashes.indexOf(hash) === -1 && supportedHashes.indexOf('ripemd160') !== -1) {
9+
hash = 'ripemd160'
10+
}
11+
12+
return createHash(hash).update(buffer).digest()
513
}
614

715
function sha1 (buffer) {

0 commit comments

Comments
 (0)