Created
May 30, 2018 08:55
-
-
Save mervick/e29fae634cb5a07108aca55cd37dee25 to your computer and use it in GitHub Desktop.
JS: Strong 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 generatePassword (length) { | |
| var password = '', character; | |
| while (length > password.length) { | |
| if (password.indexOf(character = String.fromCharCode(Math.floor(Math.random() * 94) + 33), Math.floor(password.length / 94) * 94) < 0) { | |
| password += character; | |
| } | |
| } | |
| return password; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment