Created
April 27, 2024 13:49
-
-
Save daanta-real/bf849aab98e7bfdc028759ac080d9ffb to your computer and use it in GitHub Desktop.
random password generator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function generateRandomPassword(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; | |
} | |
const randomPassword = generateRandomPassword(100); | |
console.log(randomPassword); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment