Skip to content

Instantly share code, notes, and snippets.

@mervick
Created May 30, 2018 08:55
Show Gist options
  • Select an option

  • Save mervick/e29fae634cb5a07108aca55cd37dee25 to your computer and use it in GitHub Desktop.

Select an option

Save mervick/e29fae634cb5a07108aca55cd37dee25 to your computer and use it in GitHub Desktop.
JS: Strong random password generator
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