aboutsummaryrefslogtreecommitdiff
path: root/src/js
diff options
context:
space:
mode:
authorIan Coleman <coleman.ian@gmail.com>2016-11-16 11:58:51 +1100
committerIan Coleman <coleman.ian@gmail.com>2016-11-16 12:12:13 +1100
commit9bc39377aa0317ffbfed3b6e29814bb26681cfd5 (patch)
tree9af3e048c957dc7e9249fd3511dca5898caf8738 /src/js
parent391c7f267f6be3356d0bffa74e2726245b5f45b2 (diff)
downloadBIP39-9bc39377aa0317ffbfed3b6e29814bb26681cfd5.tar.gz
BIP39-9bc39377aa0317ffbfed3b6e29814bb26681cfd5.tar.zst
BIP39-9bc39377aa0317ffbfed3b6e29814bb26681cfd5.zip
zxcvbn errors are caught, with strength 'unknown'
Diffstat (limited to 'src/js')
-rw-r--r--src/js/index.js21
1 files changed, 14 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;