Fix error for lack of rmd160 in Electron v4

This commit is contained in:
junderw 2019-04-02 18:57:07 +09:00
parent d4dc26fb33
commit 335ed99a1c
No known key found for this signature in database
GPG key ID: B256185D3A971908
2 changed files with 19 additions and 6 deletions

View file

@ -2,9 +2,16 @@
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const createHash = require('create-hash'); const createHash = require('create-hash');
function ripemd160(buffer) { function ripemd160(buffer) {
return createHash('rmd160') try {
.update(buffer) return createHash('rmd160')
.digest(); .update(buffer)
.digest();
}
catch (err) {
return createHash('ripemd160')
.update(buffer)
.digest();
}
} }
exports.ripemd160 = ripemd160; exports.ripemd160 = ripemd160;
function sha1(buffer) { function sha1(buffer) {

View file

@ -1,9 +1,15 @@
const createHash = require('create-hash'); const createHash = require('create-hash');
export function ripemd160(buffer: Buffer): Buffer { export function ripemd160(buffer: Buffer): Buffer {
return createHash('rmd160') try {
.update(buffer) return createHash('rmd160')
.digest(); .update(buffer)
.digest();
} catch (err) {
return createHash('ripemd160')
.update(buffer)
.digest();
}
} }
export function sha1(buffer: Buffer): Buffer { export function sha1(buffer: Buffer): Buffer {