Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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;
- }
- // Пример использования
- const password = generatePassword(16);
- console.log(password);
- const charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_+";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement