Skip to content

Instantly share code, notes, and snippets.

@rd13
Created June 7, 2012 12:52
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 rd13/2888660 to your computer and use it in GitHub Desktop.
Save rd13/2888660 to your computer and use it in GitHub Desktop.
Javascript Generate Password
generatePassword = function(l) {
l = l ? l : 8;
var charset = "abcdefghijklnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",
retVal = "";
for (var i = 0, n = charset.length; i < l; ++i) {
retVal += charset.charAt(Math.floor(Math.random() * n));
}
return retVal;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment