aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/index.html2
-rw-r--r--src/js/index.js27
2 files changed, 29 insertions, 0 deletions
diff --git a/src/index.html b/src/index.html
index 43a8e4f..67e9101 100644
--- a/src/index.html
+++ b/src/index.html
@@ -94,6 +94,8 @@
94 <div class="filtered col-sm-9 form-control-static"></div> 94 <div class="filtered col-sm-9 form-control-static"></div>
95 <label class="col-sm-3 control-label">Raw Binary</label> 95 <label class="col-sm-3 control-label">Raw Binary</label>
96 <div class="binary col-sm-9 form-control-static"></div> 96 <div class="binary col-sm-9 form-control-static"></div>
97 <label class="col-sm-3 control-label">Binary Checksum</label>
98 <div class="checksum col-sm-9 form-control-static">&nbsp;</div>
97 <label class="col-sm-3 control-label">Word Indexes</label> 99 <label class="col-sm-3 control-label">Word Indexes</label>
98 <div class="word-indexes col-sm-9 form-control-static">&nbsp;</div> 100 <div class="word-indexes col-sm-9 form-control-static">&nbsp;</div>
99 <label class="col-sm-3 control-label">Mnemonic Length</label> 101 <label class="col-sm-3 control-label">Mnemonic Length</label>
diff --git a/src/js/index.js b/src/js/index.js
index b36e992..0d573ba 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.entropyWordIndexes = DOM.entropyContainer.find(".word-indexes"); 40 DOM.entropyWordIndexes = DOM.entropyContainer.find(".word-indexes");
41 DOM.entropyChecksum = DOM.entropyContainer.find(".checksum");
41 DOM.entropyMnemonicLength = DOM.entropyContainer.find(".mnemonic-length"); 42 DOM.entropyMnemonicLength = DOM.entropyContainer.find(".mnemonic-length");
42 DOM.entropyFilterWarning = DOM.entropyContainer.find(".filter-warning"); 43 DOM.entropyFilterWarning = DOM.entropyContainer.find(".filter-warning");
43 DOM.phrase = $(".phrase"); 44 DOM.phrase = $(".phrase");
@@ -1195,6 +1196,8 @@
1195 DOM.phrase.val(phrase); 1196 DOM.phrase.val(phrase);
1196 // Show the word indexes 1197 // Show the word indexes
1197 showWordIndexes(); 1198 showWordIndexes();
1199 // Show the checksum
1200 showChecksum();
1198 } 1201 }
1199 1202
1200 function clearEntropyFeedback() { 1203 function clearEntropyFeedback() {
@@ -1457,6 +1460,30 @@
1457 DOM.entropyWordIndexes.text(wordIndexesStr); 1460 DOM.entropyWordIndexes.text(wordIndexesStr);
1458 } 1461 }
1459 1462
1463 function showChecksum() {
1464 var phrase = DOM.phrase.val();
1465 var words = phraseToWordArray(phrase);
1466 var checksumBitlength = words.length / 3;
1467 var checksum = "";
1468 var binaryStr = "";
1469 var language = getLanguage();
1470 for (var i=words.length-1; i>=0; i--) {
1471 var word = words[i];
1472 var wordIndex = WORDLISTS[language].indexOf(word);
1473 var wordBinary = wordIndex.toString(2);
1474 while (wordBinary.length < 11) {
1475 wordBinary = "0" + wordBinary;
1476 }
1477 var binaryStr = wordBinary + binaryStr;
1478 if (binaryStr.length >= checksumBitlength) {
1479 var start = binaryStr.length - checksumBitlength;
1480 var end = binaryStr.length;
1481 checksum = binaryStr.substring(start, end);
1482 }
1483 }
1484 DOM.entropyChecksum.text(checksum);
1485 }
1486
1460 function updateCsv() { 1487 function updateCsv() {
1461 var tableCsv = "path,address,public key,private key\n"; 1488 var tableCsv = "path,address,public key,private key\n";
1462 var rows = DOM.addresses.find("tr"); 1489 var rows = DOM.addresses.find("tr");