mirror of
https://github.com/OneKeyHQ/bip39.git
synced 2026-04-18 16:32:18 +00:00
zxcvbn errors are caught, with strength 'unknown'
This commit is contained in:
@@ -810,13 +810,20 @@
|
|||||||
// If time to crack is less than one day, and password is considered
|
// If time to crack is less than one day, and password is considered
|
||||||
// strong or better based on the number of bits, rename strength to
|
// strong or better based on the number of bits, rename strength to
|
||||||
// 'easily cracked'.
|
// 'easily cracked'.
|
||||||
var z = zxcvbn(entropy.cleanStr);
|
try {
|
||||||
var timeToCrack = z.crack_times_seconds.offline_fast_hashing_1e10_per_second;
|
var z = zxcvbn(entropy.base.parts.join(""));
|
||||||
if (timeToCrack < 86400 && entropy.binaryStr.length >= 128) {
|
var timeToCrack = z.crack_times_seconds.offline_fast_hashing_1e10_per_second;
|
||||||
strength = "easily cracked";
|
if (timeToCrack < 86400 && entropy.binaryStr.length >= 128) {
|
||||||
if (z.feedback.warning != "") {
|
strength = "easily cracked";
|
||||||
strength = strength + " - " + z.feedback.warning;
|
if (z.feedback.warning != "") {
|
||||||
};
|
strength = strength + " - " + z.feedback.warning;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
strength = "unknown";
|
||||||
|
console.log("Error detecting entropy strength with zxcvbn:");
|
||||||
|
console.log(e);
|
||||||
}
|
}
|
||||||
var bitsStr = getNumberOfEntropyBits(entropy);
|
var bitsStr = getNumberOfEntropyBits(entropy);
|
||||||
var wordCount = Math.floor(entropy.binaryStr.length / 32) * 3;
|
var wordCount = Math.floor(entropy.binaryStr.length / 32) * 3;
|
||||||
|
|||||||
9
tests.js
9
tests.js
@@ -2664,6 +2664,15 @@ page.open(url, function(status) {
|
|||||||
words: 27,
|
words: 27,
|
||||||
strength: "extremely strong",
|
strength: "extremely strong",
|
||||||
},
|
},
|
||||||
|
// Next test was throwing uncaught error in zxcvbn
|
||||||
|
{
|
||||||
|
entropy: "ac2c3c4c5c6c7c8c9ctcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsksac2c3c4c5c6c7c8c9ctcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsks",
|
||||||
|
type: "card (full deck, 52 duplicates: ac 2c 3c...)",
|
||||||
|
events: 104,
|
||||||
|
bits: 226,
|
||||||
|
words: 54,
|
||||||
|
strength: "extremely strong",
|
||||||
|
},
|
||||||
];
|
];
|
||||||
// use entropy
|
// use entropy
|
||||||
page.evaluate(function() {
|
page.evaluate(function() {
|
||||||
|
|||||||
Reference in New Issue
Block a user