|
| 1 | +<!DOCTYPE html> |
| 2 | +<html lang="en"> |
| 3 | +<head> |
| 4 | + <meta charset="UTF-8"> |
| 5 | + <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| 6 | + <title>Password Generator</title> |
| 7 | + <style> |
| 8 | + body { |
| 9 | + font-family: 'Arial', sans-serif; |
| 10 | + text-align: center; |
| 11 | + margin: 0; |
| 12 | + padding: 0; |
| 13 | + background-color: #333131; |
| 14 | + display: flex; |
| 15 | + justify-content: center; |
| 16 | + align-items: center; |
| 17 | + height: 100vh; |
| 18 | + overflow: hidden; |
| 19 | + } |
| 20 | + |
| 21 | + .container { |
| 22 | + max-width: 400px; |
| 23 | + background-color: #f1eaea; |
| 24 | + border-radius: 8px; |
| 25 | + padding: 20px; |
| 26 | + box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.2); |
| 27 | + position: relative; |
| 28 | + animation: borderAnimation 2s infinite alternate; |
| 29 | + width:400px; |
| 30 | + } |
| 31 | + .line { |
| 32 | + position: absolute; |
| 33 | + width: 100%; |
| 34 | + height: 2px; |
| 35 | + background-color: #007bff; |
| 36 | + animation: moveLine 2s linear infinite; |
| 37 | + } |
| 38 | + h2 { |
| 39 | + color: #333; |
| 40 | + } |
| 41 | + |
| 42 | + label, input { |
| 43 | + display: block; |
| 44 | + margin: 10px 0; |
| 45 | + } |
| 46 | + |
| 47 | + input[type="number"] { |
| 48 | + width: 100%; |
| 49 | + padding: 10px; |
| 50 | + border: 1px solid #ccc; |
| 51 | + border-radius: 4px; |
| 52 | + } |
| 53 | + |
| 54 | + button { |
| 55 | + background-color: #c70a0a; |
| 56 | + color: #fff; |
| 57 | + border: none; |
| 58 | + padding: 10px 20px; |
| 59 | + border-radius: 4px; |
| 60 | + cursor: pointer; |
| 61 | + transition: background-color 0.3s ease; |
| 62 | + } |
| 63 | + |
| 64 | + button:hover { |
| 65 | + background-color: #0056b3; |
| 66 | + } |
| 67 | + |
| 68 | + input[type="text"] { |
| 69 | + width: 100%; |
| 70 | + padding: 10px; |
| 71 | + border: 1px solid #ccc; |
| 72 | + border-radius: 4px; |
| 73 | + margin-top: 10px; |
| 74 | + } |
| 75 | + |
| 76 | + @keyframes fadeIn { |
| 77 | + from { |
| 78 | + opacity: 0; |
| 79 | + } |
| 80 | + to { |
| 81 | + opacity: 1; |
| 82 | + } |
| 83 | + } |
| 84 | + |
| 85 | + #generatedPassword { |
| 86 | + animation: fadeIn 0.5s ease-in; |
| 87 | + } |
| 88 | + </style> |
| 89 | +</head> |
| 90 | +<body> |
| 91 | + <div class="container"> |
| 92 | + <h2>Password Generator</h2> |
| 93 | + <label for="passwordLength">Password Length:</label> |
| 94 | + <input type="number" id="passwordLength" value="12" min="6" max="30"> |
| 95 | + <br> |
| 96 | + <button onclick="generatePassword()">Generate Password</button> |
| 97 | + <br> |
| 98 | + <input type="text" id="generatedPassword" readonly> |
| 99 | + </div> |
| 100 | + |
| 101 | + <script> |
| 102 | + function generatePassword() { |
| 103 | + const passwordLength = document.getElementById('passwordLength').value; |
| 104 | + const charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_-+="; |
| 105 | + let password = ""; |
| 106 | + |
| 107 | + for (let i = 0; i < passwordLength; i++) { |
| 108 | + const randomIndex = Math.floor(Math.random() * charset.length); |
| 109 | + password += charset.charAt(randomIndex); |
| 110 | + } |
| 111 | + |
| 112 | + document.getElementById('generatedPassword').value = password; |
| 113 | + } |
| 114 | + </script> |
| 115 | +</body> |
| 116 | +</html> |
0 commit comments