diff options
-rw-r--r-- | src/js/index.js | 21 | ||||
-rw-r--r-- | tests.js | 9 |
2 files changed, 23 insertions, 7 deletions
diff --git a/src/js/index.js b/src/js/index.js index e064185..dbbd382 100644 --- a/src/js/index.js +++ b/src/js/index.js | |||
@@ -810,13 +810,20 @@ | |||
810 | // If time to crack is less than one day, and password is considered | 810 | // If time to crack is less than one day, and password is considered |
811 | // strong or better based on the number of bits, rename strength to | 811 | // strong or better based on the number of bits, rename strength to |
812 | // 'easily cracked'. | 812 | // 'easily cracked'. |
813 | var z = zxcvbn(entropy.cleanStr); | 813 | try { |
814 | var timeToCrack = z.crack_times_seconds.offline_fast_hashing_1e10_per_second; | 814 | var z = zxcvbn(entropy.base.parts.join("")); |
815 | if (timeToCrack < 86400 && entropy.binaryStr.length >= 128) { | 815 | var timeToCrack = z.crack_times_seconds.offline_fast_hashing_1e10_per_second; |
816 | strength = "easily cracked"; | 816 | if (timeToCrack < 86400 && entropy.binaryStr.length >= 128) { |
817 | if (z.feedback.warning != "") { | 817 | strength = "easily cracked"; |
818 | strength = strength + " - " + z.feedback.warning; | 818 | if (z.feedback.warning != "") { |
819 | }; | 819 | strength = strength + " - " + z.feedback.warning; |
820 | }; | ||
821 | } | ||
822 | } | ||
823 | catch (e) { | ||
824 | strength = "unknown"; | ||
825 | console.log("Error detecting entropy strength with zxcvbn:"); | ||
826 | console.log(e); | ||
820 | } | 827 | } |
821 | var bitsStr = getNumberOfEntropyBits(entropy); | 828 | var bitsStr = getNumberOfEntropyBits(entropy); |
822 | var wordCount = Math.floor(entropy.binaryStr.length / 32) * 3; | 829 | var wordCount = Math.floor(entropy.binaryStr.length / 32) * 3; |
@@ -2664,6 +2664,15 @@ page.open(url, function(status) { | |||
2664 | words: 27, | 2664 | words: 27, |
2665 | strength: "extremely strong", | 2665 | strength: "extremely strong", |
2666 | }, | 2666 | }, |
2667 | // Next test was throwing uncaught error in zxcvbn | ||
2668 | { | ||
2669 | entropy: "ac2c3c4c5c6c7c8c9ctcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsksac2c3c4c5c6c7c8c9ctcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsks", | ||
2670 | type: "card (full deck, 52 duplicates: ac 2c 3c...)", | ||
2671 | events: 104, | ||
2672 | bits: 226, | ||
2673 | words: 54, | ||
2674 | strength: "extremely strong", | ||
2675 | }, | ||
2667 | ]; | 2676 | ]; |
2668 | // use entropy | 2677 | // use entropy |
2669 | page.evaluate(function() { | 2678 | page.evaluate(function() { |