mirror of https://github.com/status-im/bip39.git
index: use consistent slicing method
This commit is contained in:
parent
b41eefd395
commit
4ddf561dd0
6
index.js
6
index.js
|
@ -58,8 +58,8 @@ BIP39.prototype.validate = function(mnemonic) {
|
||||||
|
|
||||||
// split the binary string into ENT/CS
|
// split the binary string into ENT/CS
|
||||||
var dividerIndex = Math.floor(bits.length / 33) * 32
|
var dividerIndex = Math.floor(bits.length / 33) * 32
|
||||||
var entropy = bits.substring(0, dividerIndex)
|
var entropy = bits.slice(0, dividerIndex)
|
||||||
var checksum = bits.substring(dividerIndex)
|
var checksum = bits.slice(dividerIndex)
|
||||||
|
|
||||||
// calculate the checksum and compare
|
// calculate the checksum and compare
|
||||||
var entropyBytes = entropy.match(/(.{1,8})/g).map(function(bin) {
|
var entropyBytes = entropy.match(/(.{1,8})/g).map(function(bin) {
|
||||||
|
@ -78,7 +78,7 @@ function checksumBits(entropyBuffer) {
|
||||||
var ENT = entropyBuffer.length * 8
|
var ENT = entropyBuffer.length * 8
|
||||||
var CS = ENT / 32
|
var CS = ENT / 32
|
||||||
|
|
||||||
return bytesToBinary([].slice.call(hash)).substr(0, CS)
|
return bytesToBinary([].slice.call(hash)).slice(0, CS)
|
||||||
}
|
}
|
||||||
|
|
||||||
function salt(password) {
|
function salt(password) {
|
||||||
|
|
Loading…
Reference in New Issue