Browse Source
Fix error for lack of rmd160 in Electron v4
fixTypes
junderw
6 years ago
No known key found for this signature in database
GPG Key ID: B256185D3A971908
2 changed files with
19 additions and
6 deletions
-
src/crypto.js
-
ts_src/crypto.ts
|
|
@ -2,9 +2,16 @@ |
|
|
|
Object.defineProperty(exports, "__esModule", { value: true }); |
|
|
|
const createHash = require('create-hash'); |
|
|
|
function ripemd160(buffer) { |
|
|
|
return createHash('rmd160') |
|
|
|
.update(buffer) |
|
|
|
.digest(); |
|
|
|
try { |
|
|
|
return createHash('rmd160') |
|
|
|
.update(buffer) |
|
|
|
.digest(); |
|
|
|
} |
|
|
|
catch (err) { |
|
|
|
return createHash('ripemd160') |
|
|
|
.update(buffer) |
|
|
|
.digest(); |
|
|
|
} |
|
|
|
} |
|
|
|
exports.ripemd160 = ripemd160; |
|
|
|
function sha1(buffer) { |
|
|
|
|
|
@ -1,9 +1,15 @@ |
|
|
|
const createHash = require('create-hash'); |
|
|
|
|
|
|
|
export function ripemd160(buffer: Buffer): Buffer { |
|
|
|
return createHash('rmd160') |
|
|
|
.update(buffer) |
|
|
|
.digest(); |
|
|
|
try { |
|
|
|
return createHash('rmd160') |
|
|
|
.update(buffer) |
|
|
|
.digest(); |
|
|
|
} catch (err) { |
|
|
|
return createHash('ripemd160') |
|
|
|
.update(buffer) |
|
|
|
.digest(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
export function sha1(buffer: Buffer): Buffer { |
|
|
|