aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/js/index.js11
-rw-r--r--tests/spec/tests.js17
2 files changed, 27 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",
diff --git a/tests/spec/tests.js b/tests/spec/tests.js
index f56b18d..c7a9889 100644
--- a/tests/spec/tests.js
+++ b/tests/spec/tests.js
@@ -2937,4 +2937,21 @@ it('Shows the checksum for the entropy', function(done) {
2937 }); 2937 });
2938}); 2938});
2939 2939
2940it('Shows the checksum for the entropy with the correct groupings', function(done) {
2941 driver.findElement(By.css('.use-entropy'))
2942 .click();
2943 // create a checksum of 20 bits, which spans multiple words
2944 driver.findElement(By.css('.entropy'))
2945 .sendKeys("F000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000");
2946 driver.sleep(generateDelay).then(function() {
2947 driver.findElement(By.css('.checksum'))
2948 .getText()
2949 .then(function(text) {
2950 // first group is 9 bits, second group is 11
2951 expect(text).toBe("011010111 01110000110");
2952 done();
2953 });
2954 });
2955});
2956
2940}); 2957});