-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtool-29-Password-Strength-Meter.html
More file actions
484 lines (408 loc) · 18 KB
/
Copy pathtool-29-Password-Strength-Meter.html
File metadata and controls
484 lines (408 loc) · 18 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Tool 29 - Password Strength Meter - Developer Toolbox</title>
<link rel="stylesheet" href="assets/core.css">
<style>
.meter-container {
max-width: 600px;
margin: 2rem auto;
}
.password-input-wrapper {
position: relative;
display: flex;
align-items: center;
background: var(--bg-main);
border: 2px solid var(--border-color);
border-radius: var(--radius-md);
padding: 0.5rem 1rem;
margin-bottom: 2rem;
transition: border-color 0.3s;
}
.password-input-wrapper:focus-within {
border-color: var(--primary-color);
}
.password-input-wrapper input {
flex: 1;
background: none;
border: none;
color: var(--text-primary);
font-size: 1.5rem;
padding: 0.5rem;
outline: none;
font-family: var(--font-mono);
letter-spacing: 2px;
}
.toggle-visibility {
background: none;
border: none;
color: var(--text-secondary);
cursor: pointer;
padding: 0.5rem;
font-size: 1.2rem;
}
.gauge-container {
margin-bottom: 2rem;
}
.gauge-bar {
height: 12px;
background: rgba(255,255,255,0.1);
border-radius: 6px;
overflow: hidden;
margin-bottom: 0.5rem;
}
.gauge-fill {
height: 100%;
width: 0%;
background: var(--primary-color);
transition: width 0.4s ease, background-color 0.4s ease;
}
.gauge-labels {
display: flex;
justify-content: space-between;
color: var(--text-secondary);
font-size: 0.9rem;
font-weight: bold;
}
.stats-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 1rem;
margin-bottom: 2rem;
}
.stat-card {
background: rgba(255,255,255,0.02);
border: 1px solid var(--border-color);
padding: 1rem;
border-radius: var(--radius-sm);
text-align: center;
}
.stat-value {
font-size: 1.5rem;
font-weight: bold;
color: var(--primary-color);
margin-bottom: 0.2rem;
font-family: var(--font-mono);
}
.stat-label {
color: var(--text-secondary);
font-size: 0.85rem;
text-transform: uppercase;
letter-spacing: 1px;
}
.feedback-list {
list-style: none;
padding: 0;
margin: 0;
}
.feedback-item {
display: flex;
align-items: flex-start;
gap: 0.5rem;
margin-bottom: 0.8rem;
padding: 1rem;
border-radius: var(--radius-sm);
font-size: 0.95rem;
line-height: 1.4;
}
.feedback-item.warning {
background: rgba(255, 165, 0, 0.1);
border-left: 4px solid orange;
}
.feedback-item.success {
background: rgba(46, 160, 67, 0.1);
border-left: 4px solid #7ee787;
}
/* Strength Colors */
.strength-0 { background-color: #ff4444; }
.strength-1 { background-color: #ff4444; }
.strength-2 { background-color: #ffaa00; }
.strength-3 { background-color: #00cc00; }
.strength-4 { background-color: #00ffcc; }
#strength-text {
font-size: 1.2rem;
text-transform: uppercase;
letter-spacing: 2px;
}
</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>29. Password Strength Meter</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="glass-panel meter-container">
<div class="password-input-wrapper">
<input type="password" id="password-input" placeholder="Type a password..." autofocus>
<button class="toggle-visibility" id="toggle-vis" title="Toggle Visibility">👁️</button>
</div>
<div class="gauge-container">
<div class="gauge-bar">
<div class="gauge-fill strength-0" id="gauge-fill"></div>
</div>
<div class="gauge-labels">
<span id="strength-text" style="color: #ff4444;">Too Weak</span>
<span id="score-text">0 / 4</span>
</div>
</div>
<div class="stats-grid">
<div class="stat-card">
<div class="stat-value" id="entropy-val">0 bits</div>
<div class="stat-label">Entropy</div>
</div>
<div class="stat-card">
<div class="stat-value" id="crack-time">Instantly</div>
<div class="stat-label">Est. Crack Time</div>
</div>
</div>
<h3>Analysis Feedback</h3>
<ul class="feedback-list" id="feedback-list">
<!-- Feedback items inserted via JS -->
<li class="feedback-item warning">
<span>⚠️</span>
<span>Start typing a password to see analysis.</span>
</li>
</ul>
</div>
</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>
document.addEventListener('DOMContentLoaded', () => {
const pwdInput = document.getElementById('password-input');
const toggleVis = document.getElementById('toggle-vis');
const gaugeFill = document.getElementById('gauge-fill');
const strengthText = document.getElementById('strength-text');
const scoreText = document.getElementById('score-text');
const entropyVal = document.getElementById('entropy-val');
const crackTime = document.getElementById('crack-time');
const feedbackList = document.getElementById('feedback-list');
let isPwdVisible = false;
toggleVis.addEventListener('click', () => {
isPwdVisible = !isPwdVisible;
pwdInput.type = isPwdVisible ? 'text' : 'password';
toggleVis.textContent = isPwdVisible ? '🙈' : '👁️';
});
const calculateEntropy = (pwd) => {
let poolSize = 0;
if (/[a-z]/.test(pwd)) poolSize += 26;
if (/[A-Z]/.test(pwd)) poolSize += 26;
if (/[0-9]/.test(pwd)) poolSize += 10;
if (/[^a-zA-Z0-9]/.test(pwd)) poolSize += 32;
if (poolSize === 0) return 0;
return Math.floor(pwd.length * Math.log2(poolSize));
};
const formatCrackTime = (entropy) => {
// Assume 100 billion guesses per second for offline attack
const guesses = Math.pow(2, entropy);
const seconds = guesses / 1e11;
if (seconds < 1) return "Instantly";
if (seconds < 60) return `${Math.floor(seconds)} seconds`;
if (seconds < 3600) return `${Math.floor(seconds/60)} minutes`;
if (seconds < 86400) return `${Math.floor(seconds/3600)} hours`;
if (seconds < 31536000) return `${Math.floor(seconds/86400)} days`;
if (seconds < 31536000 * 100) return `${Math.floor(seconds/31536000)} years`;
return "Centuries";
};
const analyzePassword = (pwd) => {
const entropy = calculateEntropy(pwd);
let score = 0;
let feedback = [];
if (pwd.length === 0) {
return { score: 0, entropy: 0, feedback: [{ type: 'warning', text: 'Start typing a password to see analysis.' }] };
}
// Length checks
if (pwd.length < 8) {
feedback.push({ type: 'warning', text: 'Password is too short. Try at least 8 characters.' });
} else if (pwd.length >= 12) {
score += 1;
feedback.push({ type: 'success', text: 'Good length.' });
}
// Variety checks
let varietyCount = 0;
if (/[a-z]/.test(pwd)) varietyCount++;
if (/[A-Z]/.test(pwd)) varietyCount++;
if (/[0-9]/.test(pwd)) varietyCount++;
if (/[^a-zA-Z0-9]/.test(pwd)) varietyCount++;
if (varietyCount === 1) {
feedback.push({ type: 'warning', text: 'Uses only one character type. Add uppercase, numbers, or symbols.' });
} else if (varietyCount >= 3) {
score += 1;
feedback.push({ type: 'success', text: 'Good character variety.' });
}
// Pattern checks
if (/^[a-zA-Z]+$/.test(pwd)) {
feedback.push({ type: 'warning', text: 'Avoid using only letters.' });
}
if (/^[0-9]+$/.test(pwd)) {
feedback.push({ type: 'warning', text: 'Avoid using only numbers.' });
}
if (/(.)\1{2,}/.test(pwd)) {
feedback.push({ type: 'warning', text: 'Repeated characters like "aaa" are easy to guess.' });
}
if (/(123|abc|qwerty|password)/i.test(pwd)) {
feedback.push({ type: 'warning', text: 'Contains common sequence or word ("123", "password", etc).' });
}
// Entropy score addition
if (entropy > 40) score += 1;
if (entropy > 60) score += 1;
if (score > 4) score = 4;
if (pwd.length < 6) score = 0;
return { score, entropy, feedback };
};
const updateUI = () => {
const pwd = pwdInput.value;
const result = analyzePassword(pwd);
// Update Gauge
const percentages = [5, 25, 50, 75, 100];
const labels = ["Too Weak", "Weak", "Fair", "Strong", "Excellent"];
const colors = ["#ff4444", "#ff4444", "#ffaa00", "#00cc00", "#00ffcc"];
gaugeFill.style.width = `${percentages[result.score]}%`;
gaugeFill.className = `gauge-fill strength-${result.score}`;
strengthText.textContent = labels[result.score];
strengthText.style.color = colors[result.score];
scoreText.textContent = `${result.score} / 4`;
// Update Stats
entropyVal.textContent = `${result.entropy} bits`;
crackTime.textContent = formatCrackTime(result.entropy);
// Update Feedback
feedbackList.innerHTML = result.feedback.map(f => `
<li class="feedback-item ${f.type}">
<span>${f.type === 'warning' ? '⚠️' : '✅'}</span>
<span>${f.text}</span>
</li>
`).join('');
// Update 3D Lock
if(window.update3DLock) {
window.update3DLock(result.score);
}
};
pwdInput.addEventListener('input', updateUI);
updateUI();
});
// 3D Visualization: A lock that changes color and grows spikes
let scene, camera, renderer, lockGroup, shackle, body, spikesGroup;
const colors = [0xff4444, 0xff4444, 0xffaa00, 0x00cc00, 0x00ffcc];
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(-6, 2, 8);
camera.lookAt(0, 0, 0);
renderer = new THREE.WebGLRenderer({ alpha: true, antialias: true });
renderer.setSize(window.innerWidth, window.innerHeight);
container.appendChild(renderer.domElement);
const ambientLight = new THREE.AmbientLight(0xffffff, 0.6);
scene.add(ambientLight);
const dirLight = new THREE.DirectionalLight(0xffffff, 0.8);
dirLight.position.set(5, 10, 5);
scene.add(dirLight);
lockGroup = new THREE.Group();
scene.add(lockGroup);
// Lock Body
const bodyGeo = new THREE.BoxGeometry(3, 2.5, 1.5);
const bodyMat = new THREE.MeshPhongMaterial({ color: 0xff4444, shininess: 80 });
body = new THREE.Mesh(bodyGeo, bodyMat);
lockGroup.add(body);
// Keyhole
const holeGeo = new THREE.CylinderGeometry(0.3, 0.3, 1.51, 16);
const holeMat = new THREE.MeshBasicMaterial({ color: 0x111111 });
const hole = new THREE.Mesh(holeGeo, holeMat);
hole.rotation.x = Math.PI / 2;
hole.position.set(0, 0.2, 0);
lockGroup.add(hole);
const hole2Geo = new THREE.BoxGeometry(0.3, 0.8, 1.51);
const hole2 = new THREE.Mesh(hole2Geo, holeMat);
hole2.position.set(0, -0.4, 0);
lockGroup.add(hole2);
// Shackle
const shackleGeo = new THREE.TorusGeometry(1, 0.3, 16, 32, Math.PI);
const shackleMat = new THREE.MeshPhongMaterial({ color: 0x888888, shininess: 100 });
shackle = new THREE.Mesh(shackleGeo, shackleMat);
shackle.position.set(0, 1.25, 0);
// Open state by default
shackle.position.y += 0.5;
lockGroup.add(shackle);
// Spikes Group
spikesGroup = new THREE.Group();
lockGroup.add(spikesGroup);
lockGroup.position.set(3, -1, 0);
window.addEventListener('resize', () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
});
animate();
}
let targetScore = 0;
let currentLockY = 1.75; // Open
let targetLockY = 1.75;
window.update3DLock = (score) => {
if(!lockGroup) return;
targetScore = score;
const matColor = new THREE.Color(colors[score]);
body.material.color.copy(matColor);
// Close shackle if score > 0
if(score > 0) {
targetLockY = 1.25; // Closed
} else {
targetLockY = 1.75; // Open
}
// Generate spikes based on score
while(spikesGroup.children.length > 0) {
spikesGroup.remove(spikesGroup.children[0]);
}
if(score >= 2) {
const numSpikes = score * 4;
const spikeGeo = new THREE.ConeGeometry(0.2, 1, 8);
const spikeMat = new THREE.MeshPhongMaterial({ color: matColor });
for(let i=0; i<numSpikes; i++) {
const spike = new THREE.Mesh(spikeGeo, spikeMat);
// Place around edges
const edge = i % 4;
if(edge === 0) spike.position.set(-1.5, Math.random() * 2 - 1, (Math.random() * 1.5) - 0.75), spike.rotation.z = Math.PI/2;
if(edge === 1) spike.position.set(1.5, Math.random() * 2 - 1, (Math.random() * 1.5) - 0.75), spike.rotation.z = -Math.PI/2;
if(edge === 2) spike.position.set(Math.random() * 3 - 1.5, Math.random() * 2 - 1, 0.75), spike.rotation.x = Math.PI/2;
if(edge === 3) spike.position.set(Math.random() * 3 - 1.5, Math.random() * 2 - 1, -0.75), spike.rotation.x = -Math.PI/2;
spikesGroup.add(spike);
}
}
};
function animate() {
requestAnimationFrame(animate);
if(lockGroup) {
lockGroup.rotation.y = Math.sin(Date.now() * 0.001) * 0.4;
lockGroup.position.y = -1 + Math.sin(Date.now() * 0.002) * 0.2;
// Animate shackle closing
currentLockY += (targetLockY - currentLockY) * 0.1;
shackle.position.y = currentLockY;
}
renderer.render(scene, camera);
}
document.addEventListener('DOMContentLoaded', init3D);
</script>
</body>
</html>