Password generatar
!DOCTYPE html>
/80382945dab298bc311181b31af0e8fa.js'>
document.write(' ');
Password Generator
document.write(' ');
document.write(' ');
JavaScript (script.js):function generatePassword() {
const passwordLength = document.getElementById("passwordLength").value;
const passwordResult = document.getElementById("passwordResult");
const charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_-+=";
let password = "";
for (let i = 0; i < passwordLength; i++) {
const randomIndex = Math.floor(Math.random() * charset.length);
password += charset.charAt(randomIndex);
}
passwordResult.textContent = "Generated Password: " + password;
}CSS (styles.css):body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
margin: 0;
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
}
.container {
text-align: center;
background-color: #fff;
padding: 20px;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
button {
margin-top: 10px;
padding: 10px 20px;
font-size: 16px;
cursor: pointer;
}
.result {
margin-top: 20px;
font-size: 18px;
font-weight: bold;
}Copy each code snippet into separate files (HTML, JavaScript, CSS) and make sure they are in the same directory. Open the HTML file in a web browser to use the password generator.
Comments