Skip to content

Instantly share code, notes, and snippets.

@cmoore4
Created February 13, 2014 03:35
Show Gist options
  • Save cmoore4/8969318 to your computer and use it in GitHub Desktop.
Save cmoore4/8969318 to your computer and use it in GitHub Desktop.
JS Password Generator
// Use: var myPassword = makePWD(10);
function makePWD(len){
// Characters to include in the generator
var vars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*()-_+=~<>;";
var pwd = '';
for(var i=0; i < len; i++){
var idx = Math.floor(Math.random()*vars.length-1);
pwd += vars.substring(idx,idx+1);
}
return pwd;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment