Add try/catch

This commit is contained in:
Ryan Zimmerman 2019-04-03 10:52:50 -04:00
parent 59d07962a4
commit 7aadfa7f4c

View file

@ -1,7 +1,18 @@
const createHash = require('create-hash')
let rmd160
try {
rmd160 = require('crypto')
.getHashes()
.includes('rmd160')
? 'rmd160'
: 'ripemd160'
} catch (err) {
rmd160 = 'rmd160'
}
function ripemd160 (buffer) {
return createHash('ripemd160').update(buffer).digest()
return createHash(rmd160).update(buffer).digest()
}
function sha1 (buffer) {