mirror of
https://github.com/status-im/bip39.git
synced 2025-02-23 09:48:05 +00:00
fix in android not support spread
use `Array.from` instead of `...`
This commit is contained in:
parent
e18e1e4e8f
commit
d42e6af7af
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user