File size: 6,246 Bytes
f864c68 | 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 | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Advanced Password Generator</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://unpkg.com/feather-icons"></script>
<style>
.password-display {
letter-spacing: 0.2em;
font-family: 'Courier New', monospace;
}
.copy-btn {
transition: all 0.3s ease;
}
.copy-btn:hover {
transform: scale(1.05);
}
.copy-btn:active {
transform: scale(0.95);
}
</style>
</head>
<body class="bg-gradient-to-br from-blue-50 to-indigo-100 min-h-screen flex items-center justify-center p-4">
<div class="max-w-md w-full bg-white rounded-xl shadow-xl overflow-hidden">
<div class="bg-indigo-600 py-4 px-6">
<h1 class="text-2xl font-bold text-white flex items-center">
<i data-feather="lock" class="mr-2"></i> Advanced Password Generator
</h1>
</div>
<div class="p-6">
<div class="mb-6">
<label class="block text-gray-700 text-sm font-medium mb-2">Generated Password:</label>
<div class="flex items-center">
<div class="password-display bg-gray-100 p-4 rounded-lg text-xl font-mono flex-grow" id="password">
Click Generate
</div>
<button class="copy-btn ml-2 bg-indigo-100 hover:bg-indigo-200 text-indigo-700 p-3 rounded-lg" id="copyBtn">
<i data-feather="copy"></i>
</button>
</div>
</div>
<div class="mb-6">
<div class="flex items-center justify-between mb-2">
<span class="text-gray-700">Fixed Password Pattern: 1Uppercase + 6Lowercase + 4Numbers + /</span>
</div>
</div>
<div class="flex flex-col space-y-3 mb-6">
<div class="flex items-center">
<input type="checkbox" id="uppercase" class="h-4 w-4 text-indigo-600 focus:ring-indigo-500 border-gray-300 rounded" checked disabled>
<label for="uppercase" class="ml-2 block text-sm text-gray-700">First character uppercase (required)</label>
</div>
<div class="flex items-center">
<input type="checkbox" id="lowercase" class="h-4 w-4 text-indigo-600 focus:ring-indigo-500 border-gray-300 rounded" checked disabled>
<label for="lowercase" class="ml-2 block text-sm text-gray-700">6 lowercase letters (required)</label>
</div>
<div class="flex items-center">
<input type="checkbox" id="numbers" class="h-4 w-4 text-indigo-600 focus:ring-indigo-500 border-gray-300 rounded" checked disabled>
<label for="numbers" class="ml-2 block text-sm text-gray-700">4 numbers (required)</label>
</div>
<div class="flex items-center">
<input type="checkbox" id="slash" class="h-4 w-4 text-indigo-600 focus:ring-indigo-500 border-gray-300 rounded" checked disabled>
<label for="slash" class="ml-2 block text-sm text-gray-700">End with slash (/) (required)</label>
</div>
</div>
<button id="generateBtn" class="w-full bg-indigo-600 hover:bg-indigo-700 text-white font-bold py-3 px-4 rounded-lg transition duration-200 flex items-center justify-center">
<i data-feather="refresh-cw" class="mr-2"></i> Generate Password
</button>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
feather.replace();
const generateBtn = document.getElementById('generateBtn');
const copyBtn = document.getElementById('copyBtn');
const passwordDisplay = document.getElementById('password');
generateBtn.addEventListener('click', generatePassword);
copyBtn.addEventListener('click', function() {
const password = passwordDisplay.textContent;
if (password !== 'Click Generate') {
navigator.clipboard.writeText(password).then(() => {
const icon = copyBtn.querySelector('i');
icon.setAttribute('data-feather', 'check');
feather.replace();
setTimeout(() => {
icon.setAttribute('data-feather', 'copy');
feather.replace();
}, 2000);
});
}
});
function generatePassword() {
const uppercaseLetters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
const lowercaseLetters = 'abcdefghijklmnopqrstuvwxyz';
const numbers = '0123456789';
// Start with uppercase letter
let password = uppercaseLetters.charAt(Math.floor(Math.random() * uppercaseLetters.length));
// Add 6 lowercase letters
for (let i = 0; i < 6; i++) {
password += lowercaseLetters.charAt(Math.floor(Math.random() * lowercaseLetters.length));
}
// Add 4 numbers
for (let i = 0; i < 4; i++) {
password += numbers.charAt(Math.floor(Math.random() * numbers.length));
}
// Add slash at the end
password += '/';
passwordDisplay.textContent = password;
// Animation effect
passwordDisplay.style.transform = 'scale(1.05)';
setTimeout(() => {
passwordDisplay.style.transform = 'scale(1)';
}, 200);
}
});
</script>
</body>
</html> |