password / index.html
sendax's picture
crea una pagina web che contenga un generatore di password cosi composte: uma maiusola come prima lettera poi 6 minuscole di seguito 4 numeri ed infine uno / - Initial Deployment
f864c68 verified
Raw History Blame Contribute Delete
6.92 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Password Generator</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://unpkg.com/feather-icons"></script>
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></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" data-aos="zoom-in">
<div class="bg-indigo-600 py-4 px-6 flex justify-between items-center">
<h1 class="text-2xl font-bold text-white flex items-center">
<i data-feather="lock" class="mr-2"></i> Password Generator
</h1>
<a href="password_generator.html" class="text-white hover:text-indigo-200 text-sm flex items-center">
Advanced Generator <i data-feather="arrow-right" class="ml-1"></i>
</a>
</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 Length: 12 characters</span>
</div>
<input type="hidden" id="lengthValue" value="12">
</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="number" class="h-4 w-4 text-indigo-600 focus:ring-indigo-500 border-gray-300 rounded" checked disabled>
<label for="number" class="ml-2 block text-sm text-gray-700">Exactly four 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');
const lengthSlider = document.getElementById('lengthSlider');
const lengthValue = document.getElementById('lengthValue');
const numberCheckbox = document.getElementById('number');
const slashCheckbox = document.getElementById('slash');
lengthSlider.addEventListener('input', function() {
lengthValue.textContent = this.value;
});
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 length = parseInt(lengthSlider.value);
const includeNumber = numberCheckbox.checked;
const includeSlash = slashCheckbox.checked;
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>