aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIan Coleman <ian@iancoleman.io>2018-03-12 10:33:07 +1100
committerIan Coleman <ian@iancoleman.io>2018-03-12 11:31:41 +1100
commitf8ca25c3381d5071426497eb3bf34ff5cdf094ee (patch)
treedff5457f94f6b0337398f78e40837172f27b518e /src
parent548d94994b97fe8d01f2712fbf82df61e3d98133 (diff)
downloadBIP39-f8ca25c3381d5071426497eb3bf34ff5cdf094ee.tar.gz
BIP39-f8ca25c3381d5071426497eb3bf34ff5cdf094ee.tar.zst
BIP39-f8ca25c3381d5071426497eb3bf34ff5cdf094ee.zip
Add spacing every 11 bits to the checksum
Diffstat (limited to 'src')
-rw-r--r--src/js/index.js11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/js/index.js b/src/js/index.js
index 0d573ba..b8a76a9 100644
--- a/src/js/index.js
+++ b/src/js/index.js
@@ -1228,7 +1228,7 @@
1228 var entropyTypeStr = getEntropyTypeStr(entropy); 1228 var entropyTypeStr = getEntropyTypeStr(entropy);
1229 var wordCount = Math.floor(numberOfBits / 32) * 3; 1229 var wordCount = Math.floor(numberOfBits / 32) * 3;
1230 var bitsPerEvent = entropy.bitsPerEvent.toFixed(2); 1230 var bitsPerEvent = entropy.bitsPerEvent.toFixed(2);
1231 var spacedBinaryStr = entropy.binaryStr.match(/.{1,11}/g).join(" " ); 1231 var spacedBinaryStr = addSpacesEveryElevenBits(entropy.binaryStr);
1232 DOM.entropyFiltered.html(entropy.cleanHtml); 1232 DOM.entropyFiltered.html(entropy.cleanHtml);
1233 DOM.entropyType.text(entropyTypeStr); 1233 DOM.entropyType.text(entropyTypeStr);
1234 DOM.entropyCrackTime.text(timeToCrack); 1234 DOM.entropyCrackTime.text(timeToCrack);
@@ -1479,6 +1479,11 @@
1479 var start = binaryStr.length - checksumBitlength; 1479 var start = binaryStr.length - checksumBitlength;
1480 var end = binaryStr.length; 1480 var end = binaryStr.length;
1481 checksum = binaryStr.substring(start, end); 1481 checksum = binaryStr.substring(start, end);
1482 // add spaces so the last group is 11 bits, not the first
1483 checksum = checksum.split("").reverse().join("")
1484 checksum = addSpacesEveryElevenBits(checksum);
1485 checksum = checksum.split("").reverse().join("")
1486 break;
1482 } 1487 }
1483 } 1488 }
1484 DOM.entropyChecksum.text(checksum); 1489 DOM.entropyChecksum.text(checksum);
@@ -1504,6 +1509,10 @@
1504 DOM.csv.val(tableCsv); 1509 DOM.csv.val(tableCsv);
1505 } 1510 }
1506 1511
1512 function addSpacesEveryElevenBits(binaryStr) {
1513 return binaryStr.match(/.{1,11}/g).join(" ");
1514 }
1515
1507 var networks = [ 1516 var networks = [
1508 { 1517 {
1509 name: "AXE - Axe", 1518 name: "AXE - Axe",