diff options
author | Ian Coleman <coleman.ian@gmail.com> | 2017-06-17 09:34:50 +1000 |
---|---|---|
committer | Ian Coleman <coleman.ian@gmail.com> | 2017-06-20 10:58:31 +1000 |
commit | 20f459ce8f78ddcbca23fcd8d220b5cc2ec24006 (patch) | |
tree | fe2137d3a77f67dc017ea948af82c392de54b69e /src | |
parent | ee42e5f7126b8cfe5e9035dde0e140e2f5879db8 (diff) | |
download | BIP39-20f459ce8f78ddcbca23fcd8d220b5cc2ec24006.tar.gz BIP39-20f459ce8f78ddcbca23fcd8d220b5cc2ec24006.tar.zst BIP39-20f459ce8f78ddcbca23fcd8d220b5cc2ec24006.zip |
Change entropy Strength to Time To Crack
See issue 78
Diffstat (limited to 'src')
-rw-r--r-- | src/index.html | 4 | ||||
-rw-r--r-- | src/js/index.js | 38 |
2 files changed, 10 insertions, 32 deletions
diff --git a/src/index.html b/src/index.html index bc8ffba..5edd68e 100644 --- a/src/index.html +++ b/src/index.html | |||
@@ -165,8 +165,8 @@ | |||
165 | <div class="col-sm-7"> | 165 | <div class="col-sm-7"> |
166 | <textarea id="entropy" rows="2" class="entropy form-control" placeholder="Accepts binary, base 6, 6-sided dice, base 10, hexadecimal, cards" data-translate-placeholder></textarea> | 166 | <textarea id="entropy" rows="2" class="entropy form-control" placeholder="Accepts binary, base 6, 6-sided dice, base 10, hexadecimal, cards" data-translate-placeholder></textarea> |
167 | <div class="row"> | 167 | <div class="row"> |
168 | <label class="col-sm-3 control-label" data-translate>Strength</label> | 168 | <label class="col-sm-3 control-label" data-translate><span class="more-info" data-translate-title title="Based on estimates from zxcvbn using Filtered Entropy">Time To Crack</span></label> |
169 | <div class="strength col-sm-3 form-control-static"></div> | 169 | <div class="crack-time col-sm-3 form-control-static"></div> |
170 | <label class="col-sm-3 control-label" data-translate>Event Count</label> | 170 | <label class="col-sm-3 control-label" data-translate>Event Count</label> |
171 | <div class="event-count col-sm-3 form-control-static"></div> | 171 | <div class="event-count col-sm-3 form-control-static"></div> |
172 | </div> | 172 | </div> |
diff --git a/src/js/index.js b/src/js/index.js index 3b86e42..2bb766d 100644 --- a/src/js/index.js +++ b/src/js/index.js | |||
@@ -30,7 +30,7 @@ | |||
30 | DOM.entropy = $(".entropy"); | 30 | DOM.entropy = $(".entropy"); |
31 | DOM.entropyFiltered = DOM.entropyContainer.find(".filtered"); | 31 | DOM.entropyFiltered = DOM.entropyContainer.find(".filtered"); |
32 | DOM.entropyType = DOM.entropyContainer.find(".type"); | 32 | DOM.entropyType = DOM.entropyContainer.find(".type"); |
33 | DOM.entropyStrength = DOM.entropyContainer.find(".strength"); | 33 | DOM.entropyCrackTime = DOM.entropyContainer.find(".crack-time"); |
34 | DOM.entropyEventCount = DOM.entropyContainer.find(".event-count"); | 34 | DOM.entropyEventCount = DOM.entropyContainer.find(".event-count"); |
35 | DOM.entropyBits = DOM.entropyContainer.find(".bits"); | 35 | DOM.entropyBits = DOM.entropyContainer.find(".bits"); |
36 | DOM.entropyBitsPerEvent = DOM.entropyContainer.find(".bits-per-event"); | 36 | DOM.entropyBitsPerEvent = DOM.entropyContainer.find(".bits-per-event"); |
@@ -915,7 +915,7 @@ | |||
915 | } | 915 | } |
916 | 916 | ||
917 | function clearEntropyFeedback() { | 917 | function clearEntropyFeedback() { |
918 | DOM.entropyStrength.text("..."); | 918 | DOM.entropyCrackTime.text("..."); |
919 | DOM.entropyType.text(""); | 919 | DOM.entropyType.text(""); |
920 | DOM.entropyWordCount.text("0"); | 920 | DOM.entropyWordCount.text("0"); |
921 | DOM.entropyEventCount.text("0"); | 921 | DOM.entropyEventCount.text("0"); |
@@ -927,37 +927,15 @@ | |||
927 | 927 | ||
928 | function showEntropyFeedback(entropy) { | 928 | function showEntropyFeedback(entropy) { |
929 | var numberOfBits = entropy.binaryStr.length; | 929 | var numberOfBits = entropy.binaryStr.length; |
930 | var strength = "extremely weak"; | 930 | var timeToCrack = "unknown"; |
931 | if (numberOfBits >= 64) { | ||
932 | strength = "very weak"; | ||
933 | } | ||
934 | if (numberOfBits >= 96) { | ||
935 | strength = "weak"; | ||
936 | } | ||
937 | if (numberOfBits >= 128) { | ||
938 | strength = "strong"; | ||
939 | } | ||
940 | if (numberOfBits >= 160) { | ||
941 | strength = "very strong"; | ||
942 | } | ||
943 | if (numberOfBits >= 192) { | ||
944 | strength = "extremely strong"; | ||
945 | } | ||
946 | // If time to crack is less than one day, and password is considered | ||
947 | // strong or better based on the number of bits, rename strength to | ||
948 | // 'easily cracked'. | ||
949 | try { | 931 | try { |
950 | var z = zxcvbn(entropy.base.parts.join("")); | 932 | var z = zxcvbn(entropy.base.parts.join("")); |
951 | var timeToCrack = z.crack_times_seconds.offline_fast_hashing_1e10_per_second; | 933 | timeToCrack = z.crack_times_display.offline_fast_hashing_1e10_per_second; |
952 | if (timeToCrack < 86400 && entropy.binaryStr.length >= 128) { | 934 | if (z.feedback.warning != "") { |
953 | strength = "easily cracked"; | 935 | timeToCrack = timeToCrack + " - " + z.feedback.warning; |
954 | if (z.feedback.warning != "") { | 936 | }; |
955 | strength = strength + " - " + z.feedback.warning; | ||
956 | }; | ||
957 | } | ||
958 | } | 937 | } |
959 | catch (e) { | 938 | catch (e) { |
960 | strength = "unknown"; | ||
961 | console.log("Error detecting entropy strength with zxcvbn:"); | 939 | console.log("Error detecting entropy strength with zxcvbn:"); |
962 | console.log(e); | 940 | console.log(e); |
963 | } | 941 | } |
@@ -966,7 +944,7 @@ | |||
966 | var bitsPerEvent = entropy.bitsPerEvent.toFixed(2); | 944 | var bitsPerEvent = entropy.bitsPerEvent.toFixed(2); |
967 | DOM.entropyFiltered.html(entropy.cleanHtml); | 945 | DOM.entropyFiltered.html(entropy.cleanHtml); |
968 | DOM.entropyType.text(entropyTypeStr); | 946 | DOM.entropyType.text(entropyTypeStr); |
969 | DOM.entropyStrength.text(strength); | 947 | DOM.entropyCrackTime.text(timeToCrack); |
970 | DOM.entropyEventCount.text(entropy.base.ints.length); | 948 | DOM.entropyEventCount.text(entropy.base.ints.length); |
971 | DOM.entropyBits.text(numberOfBits); | 949 | DOM.entropyBits.text(numberOfBits); |
972 | DOM.entropyWordCount.text(wordCount); | 950 | DOM.entropyWordCount.text(wordCount); |