Created
July 6, 2021 09:52
-
-
Save oksuz/c288647350d8abfcc0b11825bcb79725 to your computer and use it in GitHub Desktop.
This file contains 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
const randomNumberGenerator = () => String.fromCharCode(parseInt(Math.random() * (57 - 49) + 49, 10)); | |
const randomStringGenerator = () => String.fromCharCode(parseInt(Math.random() * (122 - 97) + 97, 10)); | |
const randomPasswordGenerator = (len = 8, skip = ['l', '0', 'o', 'j']) => { | |
let password = ''; | |
for (let i = 0; i < len; i++) { | |
const gen = i < 2 ? randomStringGenerator() : randomNumberGenerator(); | |
if (skip.indexOf(gen) >= 0) { | |
i--; | |
continue; | |
} | |
password += gen; | |
} | |
return password; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment