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

Commit

Permalink
BG-10188 use createHash(ripemd160) if rmd160 is not supported (e.g. i…
Browse files Browse the repository at this point in the history
…n electron)
  • Loading branch information
FloBitGo committed Feb 16, 2019
1 parent 0e48e07 commit 0c3f75b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/crypto.js
@@ -1,7 +1,15 @@
var createHash = require('create-hash')
var crypto = require('crypto')

function ripemd160 (buffer) {
return createHash('rmd160').update(buffer).digest()
var hash = 'rmd160'
var supportedHashes = crypto.getHashes()
// some environments (electron) only support the long alias
if (supportedHashes.indexOf(hash) === -1 && supportedHashes.indexOf('ripemd160') !== -1) {
hash = 'ripemd160'
}

return createHash(hash).update(buffer).digest()
}

function sha1 (buffer) {
Expand Down

0 comments on commit 0c3f75b

Please sign in to comment.