diff options
author | Ian Coleman <coleman.ian@gmail.com> | 2017-09-20 10:31:28 +1000 |
---|---|---|
committer | Ian Coleman <coleman.ian@gmail.com> | 2017-09-20 11:25:21 +1000 |
commit | ee0981f1ecc4c6e78831f538ef77396c1e4fbe91 (patch) | |
tree | 9abba5e09307c9dc62c52b371576d73e369672dd /src | |
parent | 6024e655a8b6d3c35ef189013f8cd2de605171fa (diff) | |
download | BIP39-ee0981f1ecc4c6e78831f538ef77396c1e4fbe91.tar.gz BIP39-ee0981f1ecc4c6e78831f538ef77396c1e4fbe91.tar.zst BIP39-ee0981f1ecc4c6e78831f538ef77396c1e4fbe91.zip |
Detect and warn of filtered entropy
Diffstat (limited to 'src')
-rw-r--r-- | src/index.html | 7 | ||||
-rw-r--r-- | src/js/index.js | 11 |
2 files changed, 18 insertions, 0 deletions
diff --git a/src/index.html b/src/index.html index cc38ed0..7507a35 100644 --- a/src/index.html +++ b/src/index.html | |||
@@ -164,6 +164,13 @@ | |||
164 | <label for="entropy" class="col-sm-2 control-label" data-translate>Entropy</label> | 164 | <label for="entropy" class="col-sm-2 control-label" data-translate>Entropy</label> |
165 | <div class="col-sm-7"> | 165 | <div class="col-sm-7"> |
166 | <textarea id="entropy" rows="2" class="entropy form-control" placeholder="Accepts either binary, base 6, 6-sided dice, base 10, hexadecimal or cards" data-translate-placeholder></textarea> | 166 | <textarea id="entropy" rows="2" class="entropy form-control" placeholder="Accepts either binary, base 6, 6-sided dice, base 10, hexadecimal or cards" data-translate-placeholder></textarea> |
167 | <div class="row filter-warning text-danger hidden"> | ||
168 | <p class="col-sm-12"> | ||
169 | <strong> | ||
170 | Some characters have been discarded | ||
171 | </strong> | ||
172 | </p> | ||
173 | </div> | ||
167 | <div class="row"> | 174 | <div class="row"> |
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> | 175 | <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="crack-time col-sm-3 form-control-static"></div> | 176 | <div class="crack-time col-sm-3 form-control-static"></div> |
diff --git a/src/js/index.js b/src/js/index.js index 9bd77b9..6a2fea6 100644 --- a/src/js/index.js +++ b/src/js/index.js | |||
@@ -38,6 +38,7 @@ | |||
38 | DOM.entropyWordCount = DOM.entropyContainer.find(".word-count"); | 38 | DOM.entropyWordCount = DOM.entropyContainer.find(".word-count"); |
39 | DOM.entropyBinary = DOM.entropyContainer.find(".binary"); | 39 | DOM.entropyBinary = DOM.entropyContainer.find(".binary"); |
40 | DOM.entropyMnemonicLength = DOM.entropyContainer.find(".mnemonic-length"); | 40 | DOM.entropyMnemonicLength = DOM.entropyContainer.find(".mnemonic-length"); |
41 | DOM.entropyFilterWarning = DOM.entropyContainer.find(".filter-warning"); | ||
41 | DOM.phrase = $(".phrase"); | 42 | DOM.phrase = $(".phrase"); |
42 | DOM.passphrase = $(".passphrase"); | 43 | DOM.passphrase = $(".passphrase"); |
43 | DOM.generateContainer = $(".generate-container"); | 44 | DOM.generateContainer = $(".generate-container"); |
@@ -1061,6 +1062,16 @@ | |||
1061 | DOM.entropyWordCount.text(wordCount); | 1062 | DOM.entropyWordCount.text(wordCount); |
1062 | DOM.entropyBinary.text(entropy.binaryStr); | 1063 | DOM.entropyBinary.text(entropy.binaryStr); |
1063 | DOM.entropyBitsPerEvent.text(bitsPerEvent); | 1064 | DOM.entropyBitsPerEvent.text(bitsPerEvent); |
1065 | // detect and warn of filtering | ||
1066 | var rawNoSpaces = DOM.entropy.val().replace(/\s/g, ""); | ||
1067 | var cleanNoSpaces = entropy.cleanStr.replace(/\s/g, ""); | ||
1068 | var isFiltered = rawNoSpaces.length != cleanNoSpaces.length; | ||
1069 | if (isFiltered) { | ||
1070 | DOM.entropyFilterWarning.removeClass('hidden'); | ||
1071 | } | ||
1072 | else { | ||
1073 | DOM.entropyFilterWarning.addClass('hidden'); | ||
1074 | } | ||
1064 | } | 1075 | } |
1065 | 1076 | ||
1066 | function getEntropyTypeStr(entropy) { | 1077 | function getEntropyTypeStr(entropy) { |