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

Commit

Permalink
Merge pull request #23 from BitGo/BG-10188-support-ripemd160-for-elec…
Browse files Browse the repository at this point in the history
…tron

BG-10188 use ripemd160 if rmd160 is not supported
  • Loading branch information
Tyler Levine authored Feb 21, 2019
2 parents 0e48e07 + 0c3f75b commit 58bfee9
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/crypto.js
Original file line number Diff line number Diff line change
@@ -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 58bfee9

Please sign in to comment.