Created
June 2, 2014 10:04
-
-
Save askehansen/2cc2d149cde52141c1c2 to your computer and use it in GitHub Desktop.
Generate random password
This file contains hidden or 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
function generatePassword(length) { | |
var charset = "abcdefghijklnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", | |
retVal = ""; | |
for (var i = 0, n = charset.length; i < length; ++i) { | |
retVal += charset.charAt(Math.floor(Math.random() * n)); | |
} | |
return retVal; | |
} | |
document.activeElement.value = prompt('Password:', generatePassword(16)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment