|
2 | 2 | <html>
|
3 | 3 | <head>
|
4 | 4 | <title>PassSHAfe</title>
|
5 |
| - <link rel="stylesheet" href="bootstrap/bootstrap.min.css"> |
| 5 | + <link href="bootstrap/bootstrap.min.css" rel="stylesheet"> |
6 | 6 | <script src="jquery.min.js"></script>
|
7 | 7 | <script src="bootstrap/bootstrap.min.js"></script>
|
8 | 8 |
|
9 |
| - <link rel="stylesheet" href="snackbar.css"> |
| 9 | + <link href="snackbar.css" rel="stylesheet"> |
10 | 10 | <script src="passshafe.js"></script>
|
11 | 11 | <script>
|
12 | 12 | function showSnackbar(text) {
|
|
82 | 82 | return digestToColor(digest);
|
83 | 83 | }
|
84 | 84 |
|
85 |
| - function updateCanvas() { |
| 85 | + function updateCanvas(step) { |
86 | 86 | let ctx = $("#canvas")[0].getContext("2d");
|
87 | 87 | const WIDTH = 200 / 5;
|
88 | 88 | const HEIGHT = 200 / 5;
|
89 | 89 | const COLOURS = 256;
|
90 | 90 | for (let row = 0; row < 5; row++) {
|
91 | 91 | for (let col = 0; col < 3; col++) {
|
92 |
| - let pw = stringToAscii($("#masterkey").val()).concat([row, col]); |
93 |
| - let revpw = pw.reverse(); |
94 |
| - let digest = hmac(hmac(revpw, pw), hmac(pw, revpw)); |
95 |
| - let num = 0; |
96 |
| - for (let i = 0; i < 32; i++) |
97 |
| - num += expmod(256, i, COLOURS) * digest[31 - i]; |
98 |
| - ctx.fillStyle = colorForNum(num % COLOURS); |
| 92 | + if (3 * Math.abs(row - 2) + (row % 2 === 1 ? col : (2 - col)) > step) { |
| 93 | + ctx.fillStyle = "#eeeeee"; |
| 94 | + } else { |
| 95 | + let pw = stringToAscii($("#masterkey").val()).concat([row, col]); |
| 96 | + let revpw = pw.reverse(); |
| 97 | + let digest = hmac(hmac(revpw, pw), hmac(pw, revpw)); |
| 98 | + let num = 0; |
| 99 | + for (let i = 0; i < 32; i++) |
| 100 | + num += expmod(256, i, COLOURS) * digest[31 - i]; |
| 101 | + ctx.fillStyle = colorForNum(num % COLOURS); |
| 102 | + } |
99 | 103 | ctx.fillRect(col * WIDTH, row * HEIGHT, WIDTH, HEIGHT);
|
100 | 104 | ctx.fillRect((4 - col) * WIDTH, row * HEIGHT, WIDTH, HEIGHT);
|
101 | 105 | }
|
102 | 106 | }
|
| 107 | + if (step < 9) |
| 108 | + canvasTimer = setTimeout(function () { |
| 109 | + canvasTimer = undefined; |
| 110 | + updateCanvas(step + 1); |
| 111 | + }, 100); |
103 | 112 | }
|
104 | 113 |
|
105 | 114 | $(function () {
|
|
136 | 145 | if ($("#masterkey").prop("type") === "password") {
|
137 | 146 | $("#masterkey").prop("type", "text");
|
138 | 147 | $("#mishow")[0].classList.replace("glyphicon-eye-close", "glyphicon-eye-open");
|
139 |
| - } |
140 |
| - else { |
| 148 | + } else { |
141 | 149 | $("#masterkey").prop("type", "password");
|
142 | 150 | $("#mishow")[0].classList.replace("glyphicon-eye-open", "glyphicon-eye-close");
|
143 | 151 | }
|
|
147 | 155 | if ($("#genpw").prop("type") === "password") {
|
148 | 156 | $("#genpw").prop("type", "text");
|
149 | 157 | $("#gishow")[0].classList.replace("glyphicon-eye-close", "glyphicon-eye-open");
|
150 |
| - } |
151 |
| - else { |
| 158 | + } else { |
152 | 159 | $("#genpw").prop("type", "password");
|
153 | 160 | $("#gishow")[0].classList.replace("glyphicon-eye-open", "glyphicon-eye-close");
|
154 | 161 | }
|
|
166 | 173 | clearTimeout(canvasTimer);
|
167 | 174 | canvasTimer = setTimeout(function () {
|
168 | 175 | canvasTimer = undefined;
|
169 |
| - updateCanvas(); |
170 |
| - }, 1000); |
| 176 | + updateCanvas(0); |
| 177 | + }, 100); |
171 | 178 | });
|
172 | 179 | });
|
173 | 180 | </script>
|
|
207 | 214 | <div class="col-xs-8">
|
208 | 215 | <div class="input-group">
|
209 | 216 | <span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
|
210 |
| - <input id="account" type="text" class="form-control" |
211 |
| - placeholder="Account Identifier"> |
| 217 | + <input class="form-control" id="account" placeholder="Account Identifier" |
| 218 | + type="text"> |
212 | 219 | </div>
|
213 | 220 | </div>
|
214 | 221 | <div class="col-xs-4">
|
215 | 222 | <div class="input-group">
|
216 | 223 | <span class="input-group-addon"><i class="glyphicon glyphicon-cog"></i></span>
|
217 |
| - <input id="pwlength" type="number" class="form-control" |
218 |
| - placeholder="Password Length" min="1" max="256" value="24"> |
| 224 | + <input class="form-control" id="pwlength" max="256" |
| 225 | + min="1" placeholder="Password Length" type="number" value="24"> |
219 | 226 | </div>
|
220 | 227 | </div>
|
221 | 228 | </div>
|
222 | 229 | <div class="input-group">
|
223 | 230 | <span class="input-group-addon"><i class="glyphicon glyphicon-random"></i></span>
|
224 |
| - <input id="genpw" class="form-control" type="text" placeholder="Generated Password" |
225 |
| - readonly> |
| 231 | + <input class="form-control" id="genpw" placeholder="Generated Password" readonly |
| 232 | + type="text"> |
226 | 233 | <div class="input-group-btn">
|
227 | 234 | <button class="btn btn-default" id="genpwshow">
|
228 |
| - <i id="gishow" class="glyphicon glyphicon-eye-open"></i> |
| 235 | + <i class="glyphicon glyphicon-eye-open" id="gishow"></i> |
229 | 236 | </button>
|
230 | 237 | </div>
|
231 | 238 | </div>
|
232 | 239 | <div class="input-group btn-block form-group" style="margin-top: 12px">
|
233 |
| - <button id="copy" class="btn btn-primary btn-block">Copy Password to Clipboard</button> |
| 240 | + <button class="btn btn-primary btn-block" id="copy">Copy Password to Clipboard</button> |
234 | 241 | </div>
|
235 | 242 | </div>
|
236 | 243 | </div>
|
|
248 | 255 | <h4 class="modal-title">Enter your Master Password</h4>
|
249 | 256 | </div>
|
250 | 257 | <div class="modal-body">
|
251 |
| - <canvas class="center-block" style="margin-bottom: 7px" id="canvas" width="200" |
252 |
| - height="200"></canvas> |
| 258 | + <canvas class="center-block" height="200" id="canvas" style="margin-bottom: 7px" |
| 259 | + width="200"></canvas> |
253 | 260 | <div class="input-group">
|
254 | 261 | <span class="input-group-addon"><i class="glyphicon glyphicon-lock"></i></span>
|
255 |
| - <input class="form-control" type="password" placeholder="Master Password" id="masterkey"> |
| 262 | + <input class="form-control" id="masterkey" placeholder="Master Password" type="password"> |
256 | 263 | <div class="input-group-btn">
|
257 | 264 | <button class="btn btn-default" id="masterkeyshow">
|
258 |
| - <i id="mishow" class="glyphicon glyphicon-eye-close"></i> |
| 265 | + <i class="glyphicon glyphicon-eye-close" id="mishow"></i> |
259 | 266 | </button>
|
260 | 267 | </div>
|
261 | 268 | </div>
|
|
0 commit comments