Skip to content

Instantly share code, notes, and snippets.

@MaanooAk
Created June 26, 2017 09:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MaanooAk/db1acd0f33a4cf5d5f7b88640351ac9d to your computer and use it in GitHub Desktop.
Save MaanooAk/db1acd0f33a4cf5d5f7b88640351ac9d to your computer and use it in GitHub Desktop.
function random_password(length) {
var characters = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
var password = "";
for (var i = 0; i < length; i++) {
var random_float = Math.random();
password += characters.charAt(Math.floor(random_float * characters.length));
}
return password;
}
// minified
function random_password(c){for(var a="",b=0;b<c;b++)a+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".charAt(Math.floor(62*Math.random()));return a};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment