Password Generator

vnm0

vnm0

Infinity Member
Joined
October 16, 2024
Messages
168
Reaction score
1,279
Points
93
  • Thread Author
  • #1
Code:
<!DOCTYPE html>
<html>
<head>
<title>Password Generator</title>
</head>
<body>
<h1>Password Generator</h1>
<button id="generate">Generate Password</button>
<input type="text" id="password" readonly>

<script>
// Function to generate a random password
function generatePassword(length) {
const charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+";
let password = "";
for (let i = 0; i < length; i++) {
const randomIndex = Math.floor(Math.random() * charset.length);
password += charset[randomIndex];
}
return password;
}

// Function to update the password input field
function updatePasswordField() {
const passwordField = document..value = generatePassword(passwordLength);
}

// Attach the function to the "Generate Password" button
const generateButton = document..addEventListener("click", updatePasswordField);

// Generate an initial password when the page loads
updatePasswordField();
</script>
</body>
</html>
 

Similar threads

penthouse776
Replies
3
Views
435
mystar0904
M
penthouse776
Replies
2
Views
463
dopaminedetox
D
balckR0cket
Replies
37
Views
1K
grizzly$
G
Zemaro
Replies
15
Views
1K
HorstHimmler
H
  • Tags
    encryption tools generator online safety password password generator password security
  • Top