Last active
December 15, 2015 23:59
-
-
Save matthiassturm/5344032 to your computer and use it in GitHub Desktop.
Password generator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var generatePassword=function(len, pool){ | |
len=(typeof(len)!='undefined'?len:32); | |
pool=(typeof(pool)!='undefined'?pool:'abcdefghijklnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-_'); | |
for (var i=0, n=pool.length, pw=''; i<len; ++i){ | |
pw+=pool.charAt(Math.floor(Math.random()*n)); | |
} | |
return pw; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment