Add try/catch
This commit is contained in:
parent
59d07962a4
commit
7aadfa7f4c
1 changed files with 12 additions and 1 deletions
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue