From 7aadfa7f4c8ab0de80e3450cffab139fb0ff0626 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Wed, 3 Apr 2019 10:52:50 -0400 Subject: [PATCH] Add try/catch --- src/crypto.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/crypto.js b/src/crypto.js index 87f6571..604cd0c 100644 --- a/src/crypto.js +++ b/src/crypto.js @@ -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) {