diff options
author | Ian Coleman <ian@iancoleman.io> | 2019-11-11 10:15:49 +1100 |
---|---|---|
committer | Ian Coleman <ian@iancoleman.io> | 2019-11-11 10:15:49 +1100 |
commit | d93f2ba9f074464f5e20f9711563ff08e3eb19a6 (patch) | |
tree | 59998d1390551db2dacc92334fec9909bb17db4a | |
parent | 96ee8ab0a0e589c1fab745953909a031f79a3873 (diff) | |
download | BIP39-d93f2ba9f074464f5e20f9711563ff08e3eb19a6.tar.gz BIP39-d93f2ba9f074464f5e20f9711563ff08e3eb19a6.tar.zst BIP39-d93f2ba9f074464f5e20f9711563ff08e3eb19a6.zip |
Remove trailing comments
-rw-r--r-- | src/js/index.js | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/src/js/index.js b/src/js/index.js index edd70c5..472d392 100644 --- a/src/js/index.js +++ b/src/js/index.js | |||
@@ -1450,27 +1450,27 @@ | |||
1450 | } | 1450 | } |
1451 | 1451 | ||
1452 | function writeSplitPhrase(phrase) { | 1452 | function writeSplitPhrase(phrase) { |
1453 | var wordCount = phrase.split(/\s/g).length; //get number of words in phrase | 1453 | var wordCount = phrase.split(/\s/g).length; |
1454 | var left=[]; //initialize array of indexs | 1454 | var left=[]; |
1455 | for (var i=0;i<wordCount;i++) left.push(i); //add all indexs to array | 1455 | for (var i=0;i<wordCount;i++) left.push(i); |
1456 | var group=[[],[],[]], //make array for 3 groups | 1456 | var group=[[],[],[]], |
1457 | groupI=-1; //initialize group index | 1457 | groupI=-1; |
1458 | var seed = Math.abs(sjcl.hash.sha256.hash(phrase)[0])% 2147483647; //start seed at sudo random value based on hash of words | 1458 | var seed = Math.abs(sjcl.hash.sha256.hash(phrase)[0])% 2147483647; |
1459 | while (left.length>0) { //while indexs left | 1459 | while (left.length>0) { |
1460 | groupI=(groupI+1)%3; //get next group to insert index into | 1460 | groupI=(groupI+1)%3; |
1461 | seed = seed * 16807 % 2147483647; //change random value.(simple predicatable random number generator works well for this use) | 1461 | seed = seed * 16807 % 2147483647; |
1462 | var selected=Math.floor(left.length*(seed - 1) / 2147483646); //get index in left we will use for this group | 1462 | var selected=Math.floor(left.length*(seed - 1) / 2147483646); |
1463 | group[groupI].push(left[selected]); //add index to group | 1463 | group[groupI].push(left[selected]); |
1464 | left.splice(selected,1); //remove selected index | 1464 | left.splice(selected,1); |
1465 | } | 1465 | } |
1466 | var cards=[phrase.split(/\s/g),phrase.split(/\s/g),phrase.split(/\s/g)];//make array of cards | 1466 | var cards=[phrase.split(/\s/g),phrase.split(/\s/g),phrase.split(/\s/g)]; |
1467 | for (var i=0;i<3;i++) { //go through each card | 1467 | for (var i=0;i<3;i++) { |
1468 | for (var ii=0;ii<wordCount/3;ii++) cards[i][group[i][ii]]='XXXX'; //erase words listed in the group | 1468 | for (var ii=0;ii<wordCount/3;ii++) cards[i][group[i][ii]]='XXXX'; |
1469 | cards[i]='Card '+(i+1)+': '+wordArrayToPhrase(cards[i]); //combine words on card back to string | 1469 | cards[i]='Card '+(i+1)+': '+wordArrayToPhrase(cards[i]); |
1470 | } | 1470 | } |
1471 | DOM.splitPhrase.val(cards.join("\r\n")); //make words visible | 1471 | DOM.splitPhrase.val(cards.join("\r\n")); |
1472 | var triesPerSecond=10000000000; //assumed number of tries per second | 1472 | var triesPerSecond=10000000000; |
1473 | var hackTime=Math.pow(2,wordCount*10/3)/triesPerSecond; //get number of bits of unknown data per card | 1473 | var hackTime=Math.pow(2,wordCount*10/3)/triesPerSecond; |
1474 | if (hackTime<1) { | 1474 | if (hackTime<1) { |
1475 | hackTime="<1 second"; | 1475 | hackTime="<1 second"; |
1476 | } else if (hackTime<86400) { | 1476 | } else if (hackTime<86400) { |