HTMLify
Password Generator
Views: 308 | Author: djdj
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 | <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Password Generator</title> <style> body { font-family: Arial, sans-serif; background: #1e1e1e; color: #fff; display: flex; justify-content: center; align-items: center; height: 100vh; } .container { background: #2c2c2c; padding: 20px; border-radius: 10px; width: 300px; text-align: center; } .password-box { display: flex; margin-bottom: 10px; } .password-box input { flex: 1; padding: 8px; font-size: 16px; border: none; border-radius: 4px 0 0 4px; } .password-box button { padding: 8px; border: none; background: #ffc107; margin-top:-0px; color: #000; border-radius: 0 4px 4px 0; cursor: pointer; } .slider-container { margin: 15px 0; } input[type="range"] { width: 100%; } .settings label { display: block; margin: 5px 0; text-align: left; font-size: 14px; } button { background: #ffcc00; padding: 10px; width: 100%; border: none; margin-top: 15px; cursor: pointer; font-weight: bold; border-radius: 6px; } </style> </head> <body> <div class="container"> <h2>Password Generator</h2> <div class="password-box"> <input type="text" id="password" readonly> <button onclick="copyPassword()">📋</button> </div> <div class="slider-container"> <label>Password Length</label> <input type="range" id="lengthSlider" min="4" max="32" value="15" oninput="updateLength()"> <span id="lengthValue">15</span> </div> <div class="settings"> <label><input type="checkbox" id="lowercase" checked> Lowercase (a-z)</label> <label><input type="checkbox" id="uppercase"> Uppercase (A-Z)</label> <label><input type="checkbox" id="numbers"> Numbers (0-9)</label> <label><input type="checkbox" id="symbols"> Symbols ($+^)</label> <label><input type="checkbox" id="excludeDuplicate"> Exclude Duplicate</label> <label><input type="checkbox" id="includeSpaces"> Include Spaces</label> </div> <button onclick="generatePassword()">Generate Password</button> </div> <script> function updateLength() { document.getElementById('lengthValue').innerText = document.getElementById('lengthSlider').value; } function copyPassword() { const password = document.getElementById("password"); password.select(); document.execCommand("copy"); alert("Password copied!"); } function generatePassword() { const length = +document.getElementById('lengthSlider').value; const lowercase = document.getElementById('lowercase').checked; const uppercase = document.getElementById('uppercase').checked; const numbers = document.getElementById('numbers').checked; const symbols = document.getElementById('symbols').checked; const excludeDuplicate = document.getElementById('excludeDuplicate').checked; const includeSpaces = document.getElementById('includeSpaces').checked; const lowerSet = 'abcdefghijklmnopqrstuvwxyz'; const upperSet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; const numberSet = '0123456789'; const symbolSet = '~!@#$%^&*()_+{}|:<>?'; const space = ' '; let chars = ''; if (lowercase) chars += lowerSet; if (uppercase) chars += upperSet; if (numbers) chars += numberSet; if (symbols) chars += symbolSet; if (includeSpaces) chars += space; let password = ''; let usedChars = new Set(); for (let i = 0; i < length; i++) { let char = chars[Math.floor(Math.random() * chars.length)]; if (excludeDuplicate) { while (usedChars.has(char) && usedChars.size < chars.length) { char = chars[Math.floor(Math.random() * chars.length)]; } usedChars.add(char); } password += char; } document.getElementById("password").value = password || 'Enable options'; } </script> </body> </html> |