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

Commit 58bfee9

Browse files
author
Tyler Levine
authored
Merge pull request #23 from BitGo/BG-10188-support-ripemd160-for-electron
BG-10188 use ripemd160 if rmd160 is not supported
2 parents 0e48e07 + 0c3f75b commit 58bfee9

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)