Browse Source
fix in android not support spread
use `Array.from` instead of `...`
master
Mr.jiangzhiguo
5 years ago
committed by
junderw
No known key found for this signature in database
GPG Key ID: B256185D3A971908
2 changed files with
4 additions and
4 deletions
-
src/index.js
-
ts_src/index.ts
|
|
@ -27,7 +27,7 @@ function deriveChecksumBits(entropyBuffer) { |
|
|
|
const hash = createHash('sha256') |
|
|
|
.update(entropyBuffer) |
|
|
|
.digest(); |
|
|
|
return bytesToBinary([...hash]).slice(0, CS); |
|
|
|
return bytesToBinary(Array.from(hash)).slice(0, CS); |
|
|
|
} |
|
|
|
function salt(password) { |
|
|
|
return 'mnemonic' + (password || ''); |
|
|
@ -106,7 +106,7 @@ function entropyToMnemonic(entropy, wordlist) { |
|
|
|
throw new TypeError(INVALID_ENTROPY); |
|
|
|
if (entropy.length % 4 !== 0) |
|
|
|
throw new TypeError(INVALID_ENTROPY); |
|
|
|
const entropyBits = bytesToBinary([...entropy]); |
|
|
|
const entropyBits = bytesToBinary(Array.from(entropy)); |
|
|
|
const checksumBits = deriveChecksumBits(entropy); |
|
|
|
const bits = entropyBits + checksumBits; |
|
|
|
const chunks = bits.match(/(.{1,11})/g); |
|
|
|
|
|
@ -32,7 +32,7 @@ function deriveChecksumBits(entropyBuffer: Buffer): string { |
|
|
|
.update(entropyBuffer) |
|
|
|
.digest(); |
|
|
|
|
|
|
|
return bytesToBinary([...hash]).slice(0, CS); |
|
|
|
return bytesToBinary(Array.from(hash)).slice(0, CS); |
|
|
|
} |
|
|
|
|
|
|
|
function salt(password?: string): string { |
|
|
@ -136,7 +136,7 @@ export function entropyToMnemonic( |
|
|
|
if (entropy.length > 32) throw new TypeError(INVALID_ENTROPY); |
|
|
|
if (entropy.length % 4 !== 0) throw new TypeError(INVALID_ENTROPY); |
|
|
|
|
|
|
|
const entropyBits = bytesToBinary([...entropy]); |
|
|
|
const entropyBits = bytesToBinary(Array.from(entropy)); |
|
|
|
const checksumBits = deriveChecksumBits(entropy); |
|
|
|
|
|
|
|
const bits = entropyBits + checksumBits; |
|
|
|