Browse Source

Fix error for lack of rmd160 in Electron v4

fixTypes
junderw 6 years ago
parent
commit
335ed99a1c
No known key found for this signature in database GPG Key ID: B256185D3A971908
  1. 7
      src/crypto.js
  2. 6
      ts_src/crypto.ts

7
src/crypto.js

@ -2,10 +2,17 @@
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) {
try {
return createHash('rmd160') return createHash('rmd160')
.update(buffer) .update(buffer)
.digest(); .digest();
} }
catch (err) {
return createHash('ripemd160')
.update(buffer)
.digest();
}
}
exports.ripemd160 = ripemd160; exports.ripemd160 = ripemd160;
function sha1(buffer) { function sha1(buffer) {
return createHash('sha1') return createHash('sha1')

6
ts_src/crypto.ts

@ -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 {
try {
return createHash('rmd160') return createHash('rmd160')
.update(buffer) .update(buffer)
.digest(); .digest();
} catch (err) {
return createHash('ripemd160')
.update(buffer)
.digest();
}
} }
export function sha1(buffer: Buffer): Buffer { export function sha1(buffer: Buffer): Buffer {

Loading…
Cancel
Save