Skip to content

Instantly share code, notes, and snippets.

@ykhs
Created August 9, 2012 04:21
Show Gist options
  • Save ykhs/3300910 to your computer and use it in GitHub Desktop.
Save ykhs/3300910 to your computer and use it in GitHub Desktop.
generate password like string
var password = [].reduce.call('AaBbCcDdEeFfGgHhiJjKkLMmNnPpQqRrSsTtWwXxYyz3456789', function(p, c, i, a) {
return p += a.replace(new RegExp(p.split('').join('|'), 'g'), '')[Math.floor(Math.random() * (a.length - p.length))];
}, '').substr(0, 16);
console.log(password);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment