aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIan Coleman <coleman.ian@gmail.com>2016-11-10 10:54:43 +1100
committerIan Coleman <coleman.ian@gmail.com>2016-11-10 10:54:43 +1100
commita3d78b7ddc5aa936d42f2952b9bbab5cd5820dfd (patch)
tree1922fc9a6774f80c7515b9973fe1b74794438678 /src
parent0d0f07f9374078ba71cf7f81cd6c2ab8df8d4693 (diff)
downloadBIP39-a3d78b7ddc5aa936d42f2952b9bbab5cd5820dfd.tar.gz
BIP39-a3d78b7ddc5aa936d42f2952b9bbab5cd5820dfd.tar.zst
BIP39-a3d78b7ddc5aa936d42f2952b9bbab5cd5820dfd.zip
Dice conversion to Base 6 uses arrays not strings
Diffstat (limited to 'src')
-rw-r--r--src/js/entropy.js13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/js/entropy.js b/src/js/entropy.js
index c804fda..cf981ff 100644
--- a/src/js/entropy.js
+++ b/src/js/entropy.js
@@ -70,23 +70,22 @@ window.Entropy = new (function() {
70 // Convert dice to base6 entropy (ie 1-6 to 0-5) 70 // Convert dice to base6 entropy (ie 1-6 to 0-5)
71 // This is done by changing all 6s to 0s 71 // This is done by changing all 6s to 0s
72 if (base.str == "dice") { 72 if (base.str == "dice") {
73 var newRawEntropyStr = ""; 73 var newParts = [];
74 var newInts = []; 74 var newInts = [];
75 for (var i=0; i<rawEntropyStr.length; i++) { 75 for (var i=0; i<base.parts.length; i++) {
76 var c = rawEntropyStr[i]; 76 var c = base.parts[i];
77 if ("12345".indexOf(c) > -1) { 77 if ("12345".indexOf(c) > -1) {
78 newRawEntropyStr += c; 78 newParts[i] = base.parts[i];
79 newInts[i] = base.ints[i]; 79 newInts[i] = base.ints[i];
80 } 80 }
81 else { 81 else {
82 newRawEntropyStr += "0"; 82 newParts[i] = "0";
83 newInts[i] = 0; 83 newInts[i] = 0;
84 } 84 }
85 } 85 }
86 rawEntropyStr = newRawEntropyStr;
87 base.str = "base 6 (dice)"; 86 base.str = "base 6 (dice)";
88 base.ints = newInts; 87 base.ints = newInts;
89 base.parts = matchers.base6(rawEntropyStr); 88 base.parts = newParts;
90 base.matcher = matchers.base6; 89 base.matcher = matchers.base6;
91 } 90 }
92 // Detect empty entropy 91 // Detect empty entropy