-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtool-44-Strong-Password-Generator.html
More file actions
613 lines (523 loc) · 22.9 KB
/
Copy pathtool-44-Strong-Password-Generator.html
File metadata and controls
613 lines (523 loc) · 22.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Tool 44 - Strong Password Generator - Developer Toolbox</title>
<link rel="stylesheet" href="assets/core.css">
<style>
.generator-container {
max-width: 600px;
margin: 2rem auto;
background: var(--bg-main);
border: 1px solid var(--border-color);
border-radius: var(--radius-md);
padding: 2rem;
position: relative;
z-index: 10;
}
.password-display {
background: rgba(0,0,0,0.5);
border: 2px solid var(--border-color);
border-radius: var(--radius-sm);
padding: 1rem 1.5rem;
font-family: var(--font-mono);
font-size: 1.8rem;
text-align: center;
color: var(--primary-color);
margin-bottom: 0.5rem;
word-break: break-all;
letter-spacing: 2px;
display: flex;
justify-content: space-between;
align-items: center;
min-height: 80px;
}
.password-actions {
display: flex;
gap: 1rem;
margin-bottom: 2rem;
}
.btn-full { flex: 1; }
.settings-group {
margin-bottom: 1.5rem;
}
.settings-header {
display: flex;
justify-content: space-between;
color: var(--text-secondary);
font-weight: bold;
margin-bottom: 0.5rem;
}
.slider-container {
display: flex;
align-items: center;
gap: 1rem;
}
input[type="range"] {
flex: 1;
accent-color: var(--primary-color);
height: 6px;
}
.length-val {
font-family: var(--font-mono);
background: rgba(255,255,255,0.1);
padding: 0.2rem 0.6rem;
border-radius: 4px;
min-width: 40px;
text-align: center;
}
.toggles-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 1rem;
margin-top: 1.5rem;
}
.toggle-row {
display: flex;
justify-content: space-between;
align-items: center;
background: rgba(255,255,255,0.02);
padding: 0.8rem;
border-radius: var(--radius-sm);
border: 1px solid var(--border-color);
}
.toggle-row:hover { background: rgba(255,255,255,0.05); }
.toggle-label {
font-weight: bold;
color: var(--text-primary);
}
input[type="checkbox"] {
width: 20px;
height: 20px;
accent-color: var(--primary-color);
cursor: pointer;
}
.strength-meter {
margin-top: 2rem;
padding-top: 1.5rem;
border-top: 1px solid var(--border-color);
}
.strength-bar-container {
display: flex;
gap: 0.3rem;
height: 8px;
margin-bottom: 0.5rem;
}
.strength-seg {
flex: 1;
border-radius: 4px;
background: rgba(255,255,255,0.1);
transition: all 0.3s;
}
.strength-text {
text-align: right;
font-weight: bold;
font-size: 0.9rem;
text-transform: uppercase;
}
.toast {
position: fixed;
bottom: 20px;
right: 20px;
background: var(--primary-color);
color: white;
padding: 10px 20px;
border-radius: var(--radius-sm);
opacity: 0;
transition: opacity 0.3s;
pointer-events: none;
z-index: 1000;
}
/* Fancy Switch */
.switch {
position: relative;
display: inline-block;
width: 46px;
height: 24px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
position: absolute;
cursor: pointer;
top: 0; left: 0; right: 0; bottom: 0;
background-color: #334;
transition: .4s;
border-radius: 24px;
}
.slider:before {
position: absolute;
content: "";
height: 18px;
width: 18px;
left: 3px;
bottom: 3px;
background-color: white;
transition: .4s;
border-radius: 50%;
}
input:checked + .slider { background-color: var(--primary-color); }
input:checked + .slider:before { transform: translateX(22px); }
</style>
</head>
<body class="theme-dark">
<div class="tool-canvas-container" id="canvas-container"></div>
<main class="main-content">
<div class="container">
<div class="tool-header">
<div>
<a href="index.html" class="back-link">← Back to Toolbox</a>
<h1>44. Strong Password Generator</h1>
</div>
<div>
<select id="theme-select" aria-label="Select Theme">
<option value="dark">Dark Theme</option>
<option value="light">Light Theme</option>
<option value="solarized">Solarized</option>
<option value="neon">Neon Glow</option>
<option value="highcontrast">High Contrast</option>
</select>
</div>
</div>
<div class="generator-container glass-panel">
<div class="password-display" id="pwd-display">
Generating...
</div>
<div class="password-actions">
<button class="btn btn-primary btn-full" id="copy-btn">📋 Copy Password</button>
<button class="btn btn-full" id="regen-btn">🔄 Regenerate</button>
</div>
<div class="settings-group">
<div class="settings-header">
<span>Password Length</span>
<span class="length-val" id="len-val">16</span>
</div>
<div class="slider-container">
<span style="color:var(--text-secondary); font-size: 0.8rem;">8</span>
<input type="range" id="len-slider" min="8" max="64" value="16">
<span style="color:var(--text-secondary); font-size: 0.8rem;">64</span>
</div>
</div>
<div class="settings-group" style="display: flex; justify-content: space-between; align-items: center; background: rgba(0,0,0,0.2); padding: 1rem; border-radius: var(--radius-sm);">
<div style="display: flex; flex-direction: column;">
<span style="font-weight: bold;">Pronounceable (Memorable)</span>
<span style="font-size: 0.8rem; color: var(--text-secondary)">Generates alternating consonant/vowel patterns</span>
</div>
<label class="switch">
<input type="checkbox" id="pronounce-toggle">
<span class="slider"></span>
</label>
</div>
<div class="toggles-grid" id="char-toggles">
<label class="toggle-row">
<span class="toggle-label">Uppercase<br><small style="color:var(--text-secondary);font-weight:normal">A-Z</small></span>
<input type="checkbox" id="chk-upper" checked>
</label>
<label class="toggle-row">
<span class="toggle-label">Lowercase<br><small style="color:var(--text-secondary);font-weight:normal">a-z</small></span>
<input type="checkbox" id="chk-lower" checked>
</label>
<label class="toggle-row">
<span class="toggle-label">Numbers<br><small style="color:var(--text-secondary);font-weight:normal">0-9</small></span>
<input type="checkbox" id="chk-nums" checked>
</label>
<label class="toggle-row">
<span class="toggle-label">Symbols<br><small style="color:var(--text-secondary);font-weight:normal">!@#$%^&*</small></span>
<input type="checkbox" id="chk-syms" checked>
</label>
</div>
<div class="strength-meter">
<div style="display: flex; justify-content: space-between; margin-bottom: 0.5rem;">
<span style="color: var(--text-secondary); font-weight: bold;">Strength</span>
<span class="strength-text" id="strength-text" style="color: #7ee787;">Strong</span>
</div>
<div class="strength-bar-container">
<div class="strength-seg" id="seg-1"></div>
<div class="strength-seg" id="seg-2"></div>
<div class="strength-seg" id="seg-3"></div>
<div class="strength-seg" id="seg-4"></div>
</div>
<div style="font-size: 0.8rem; color: var(--text-secondary); text-align: right; margin-top: 0.5rem;" id="entropy-val">~0 bits of entropy</div>
</div>
</div>
</div>
<div id="toast" class="toast">Copied to clipboard!</div>
</main>
<footer class="global-footer">
<div class="container">
Made with ❤️ by <a href="https://github.com/Aliriyaj007" target="_blank">Aliriyaj007</a>
</div>
</footer>
<script src="assets/core.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r134/three.min.js"></script>
<script>
const pwdDisplay = document.getElementById('pwd-display');
const copyBtn = document.getElementById('copy-btn');
const regenBtn = document.getElementById('regen-btn');
const lenSlider = document.getElementById('len-slider');
const lenVal = document.getElementById('len-val');
const pronounceToggle = document.getElementById('pronounce-toggle');
const charToggles = document.getElementById('char-toggles');
const chkUpper = document.getElementById('chk-upper');
const chkLower = document.getElementById('chk-lower');
const chkNums = document.getElementById('chk-nums');
const chkSyms = document.getElementById('chk-syms');
const strengthText = document.getElementById('strength-text');
const entropyVal = document.getElementById('entropy-val');
const segs = [
document.getElementById('seg-1'),
document.getElementById('seg-2'),
document.getElementById('seg-3'),
document.getElementById('seg-4')
];
const toast = document.getElementById('toast');
// Character Sets
const UPPER = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
const LOWER = 'abcdefghijklmnopqrstuvwxyz';
const NUMS = '0123456789';
const SYMS = '!@#$%^&*()_+~`|}{[]:;?><,./-=';
const VOWELS = 'aeiouy'; // Using y as vowel for pronounceability
const CONSONANTS = 'bcdfghjklmnpqrstvwxz';
// Crypto RNG
const secureMathRandom = () => {
return window.crypto.getRandomValues(new Uint32Array(1))[0] / (Math.pow(2, 32) - 1);
};
const generatePronounceable = (length) => {
let pwd = '';
for(let i=0; i<length; i++) {
if(i % 2 === 0) {
pwd += CONSONANTS[Math.floor(secureMathRandom() * CONSONANTS.length)];
} else {
pwd += VOWELS[Math.floor(secureMathRandom() * VOWELS.length)];
}
}
// Randomly capitalize a few for complexity
if(chkUpper.checked) {
pwd = pwd.split('').map(c => secureMathRandom() > 0.7 ? c.toUpperCase() : c).join('');
}
// Insert number at end if needed
if(chkNums.checked) {
pwd = pwd.substring(0, pwd.length-2) + NUMS[Math.floor(secureMathRandom()*NUMS.length)] + NUMS[Math.floor(secureMathRandom()*NUMS.length)];
}
// Insert symbol at end
if(chkSyms.checked) {
pwd = pwd.substring(0, pwd.length-1) + SYMS[Math.floor(secureMathRandom()*SYMS.length)];
}
return pwd;
};
const generateRandom = (length) => {
let chars = '';
if(chkUpper.checked) chars += UPPER;
if(chkLower.checked) chars += LOWER;
if(chkNums.checked) chars += NUMS;
if(chkSyms.checked) chars += SYMS;
if(chars.length === 0) {
chkLower.checked = true;
chars += LOWER;
}
let pwd = '';
// Ensure at least one of each selected
if(chkUpper.checked) pwd += UPPER[Math.floor(secureMathRandom() * UPPER.length)];
if(chkLower.checked) pwd += LOWER[Math.floor(secureMathRandom() * LOWER.length)];
if(chkNums.checked) pwd += NUMS[Math.floor(secureMathRandom() * NUMS.length)];
if(chkSyms.checked) pwd += SYMS[Math.floor(secureMathRandom() * SYMS.length)];
for(let i=pwd.length; i<length; i++) {
pwd += chars[Math.floor(secureMathRandom() * chars.length)];
}
// Shuffle
pwd = pwd.split('').sort(() => 0.5 - secureMathRandom()).join('');
return pwd;
};
const calculateEntropy = (pwd) => {
let pool = 0;
if(chkUpper.checked) pool += 26;
if(chkLower.checked) pool += 26;
if(chkNums.checked) pool += 10;
if(chkSyms.checked) pool += SYMS.length;
if(pronounceToggle.checked) {
// Approximate entropy for pronounceable
pool = 15; // lower effective pool
}
const entropy = pwd.length * Math.log2(pool || 1);
return Math.floor(entropy);
};
const updateStrength = (entropy) => {
let score = 0;
let color = '';
let text = '';
if(entropy < 40) { score = 1; color = '#ff5555'; text = 'Weak'; }
else if(entropy < 60) { score = 2; color = '#ffaa00'; text = 'Fair'; }
else if(entropy < 80) { score = 3; color = '#f1e05a'; text = 'Good'; }
else { score = 4; color = '#7ee787'; text = 'Strong'; }
strengthText.textContent = text;
strengthText.style.color = color;
entropyVal.textContent = `~${entropy} bits of entropy`;
segs.forEach((seg, i) => {
if(i < score) {
seg.style.background = color;
} else {
seg.style.background = 'rgba(255,255,255,0.1)';
}
});
// Update 3D Vault
if(window.update3DVaultProgress) window.update3DVaultProgress(score);
};
const updatePassword = () => {
const len = parseInt(lenSlider.value);
const isPronounceable = pronounceToggle.checked;
if(isPronounceable) {
charToggles.style.opacity = '0.5';
charToggles.style.pointerEvents = 'none';
} else {
charToggles.style.opacity = '1';
charToggles.style.pointerEvents = 'auto';
}
const pwd = isPronounceable ? generatePronounceable(len) : generateRandom(len);
pwdDisplay.textContent = pwd;
const entropy = calculateEntropy(pwd);
updateStrength(entropy);
// Trigger safe dial spin in 3D
if(window.spinDial) window.spinDial();
};
lenSlider.addEventListener('input', (e) => {
lenVal.textContent = e.target.value;
updatePassword();
});
[pronounceToggle, chkUpper, chkLower, chkNums, chkSyms].forEach(el => {
el.addEventListener('change', () => {
// Ensure at least one toggle is active if random
if(!pronounceToggle.checked && !chkUpper.checked && !chkLower.checked && !chkNums.checked && !chkSyms.checked) {
chkLower.checked = true;
}
updatePassword();
});
});
regenBtn.addEventListener('click', updatePassword);
copyBtn.addEventListener('click', () => {
navigator.clipboard.writeText(pwdDisplay.textContent);
toast.style.opacity = '1';
setTimeout(() => toast.style.opacity = '0', 2000);
});
// 3D Visualization: A vault door with spinning combination lock
let scene, camera, renderer, vaultGroup, dialGroup;
let dialTargetRot = 0;
let lockBars = [];
let vaultStrength = 0; // 1-4
function init3D() {
const container = document.getElementById('canvas-container');
if(!container || !window.THREE) return;
scene = new THREE.Scene();
camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 0.1, 100);
camera.position.set(0, 0, 15);
camera.lookAt(0, 0, 0);
renderer = new THREE.WebGLRenderer({ alpha: true, antialias: true, shadowMap: { enabled: true } });
renderer.setSize(window.innerWidth, window.innerHeight);
container.appendChild(renderer.domElement);
const ambientLight = new THREE.AmbientLight(0xffffff, 0.4);
scene.add(ambientLight);
const dirLight = new THREE.DirectionalLight(0xffffff, 0.8);
dirLight.position.set(5, 5, 5);
scene.add(dirLight);
vaultGroup = new THREE.Group();
scene.add(vaultGroup);
// Vault Door (Large cylinder)
const doorGeo = new THREE.CylinderGeometry(4, 4, 1, 32);
doorGeo.rotateX(Math.PI/2);
const doorMat = new THREE.MeshPhongMaterial({ color: 0x556677, shininess: 80, flatShading: true });
const door = new THREE.Mesh(doorGeo, doorMat);
vaultGroup.add(door);
// Dial Group
dialGroup = new THREE.Group();
dialGroup.position.z = 0.6;
vaultGroup.add(dialGroup);
// Dial Base
const dbGeo = new THREE.CylinderGeometry(1.5, 1.8, 0.4, 32);
dbGeo.rotateX(Math.PI/2);
const dbMat = new THREE.MeshPhongMaterial({ color: 0x223344 });
const dBase = new THREE.Mesh(dbGeo, dbMat);
dialGroup.add(dBase);
// Dial Knob
const dkGeo = new THREE.CylinderGeometry(0.8, 0.8, 0.6, 24);
dkGeo.rotateX(Math.PI/2);
const dkMat = new THREE.MeshPhongMaterial({ color: 0x8899aa });
const dKnob = new THREE.Mesh(dkGeo, dkMat);
dKnob.position.z = 0.3;
dialGroup.add(dKnob);
// Dial Ticks
for(let i=0; i<4; i++) {
const tickGeo = new THREE.BoxGeometry(0.1, 0.4, 0.1);
const tickMat = new THREE.MeshBasicMaterial({ color: 0xffffff });
const tick = new THREE.Mesh(tickGeo, tickMat);
tick.position.y = 1;
tick.position.z = 0.2;
const tickWrapper = new THREE.Group();
tickWrapper.rotation.z = (Math.PI/2) * i;
tickWrapper.add(tick);
dialGroup.add(tickWrapper);
}
// Lock Bars (Bolts) extending from side
for(let i=0; i<4; i++) {
const barGeo = new THREE.CylinderGeometry(0.3, 0.3, 2, 16);
barGeo.rotateZ(Math.PI/2);
const barMat = new THREE.MeshPhongMaterial({ color: 0x99aacc, shininess: 100 });
const bar = new THREE.Mesh(barGeo, barMat);
// Positioned on the left edge (when closed)
// We will move their X to simulate locking
bar.position.set(-3.5, -2.5 + (i * 1.6), 0);
vaultGroup.add(bar);
lockBars.push({ mesh: bar, targetX: -3.5 });
}
vaultGroup.position.set(-3, 0, 0);
window.addEventListener('resize', () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
});
animate();
// Initial call
setTimeout(() => { updatePassword(); }, 100);
}
window.spinDial = () => {
// Give the dial a randomized multi-spin target
dialTargetRot += (Math.random() > 0.5 ? 1 : -1) * (Math.PI * 2 + Math.random() * Math.PI * 2);
};
window.update3DVaultProgress = (score) => {
vaultStrength = score; // 1 to 4
// Map score to how many bolts are "extended/locked"
// Let's say score 1 = 1 bolt extended, score 4 = 4 bolts out.
// When extended, X = -4.5 (sticking out). When retracted, X = -3.5
lockBars.forEach((bar, idx) => {
if(idx < vaultStrength) {
bar.targetX = -4.8; // Stick out to lock
bar.mesh.material.color.setHex(0x44ff44); // Glow green indicating secured
bar.mesh.material.emissive.setHex(0x005500);
} else {
bar.targetX = -3.5; // Retracted
bar.mesh.material.color.setHex(0x99aacc); // Default metal
bar.mesh.material.emissive.setHex(0x000000);
}
});
};
function animate() {
requestAnimationFrame(animate);
if(vaultGroup) {
// Gentle floating
vaultGroup.position.y = Math.sin(Date.now() * 0.002) * 0.3;
vaultGroup.rotation.y = Math.sin(Date.now() * 0.001) * 0.2 + 0.3; // slightly angled
vaultGroup.rotation.x = Math.sin(Date.now() * 0.0015) * 0.1;
// Animate Dial Spin
if(dialGroup) {
const diff = dialTargetRot - dialGroup.rotation.z;
dialGroup.rotation.z += diff * 0.05;
}
// Animate lock bolts
lockBars.forEach(bar => {
bar.mesh.position.x += (bar.targetX - bar.mesh.position.x) * 0.1;
});
}
renderer.render(scene, camera);
}
document.addEventListener('DOMContentLoaded', init3D);
</script>
</body>
</html>