Last active
August 29, 2015 14:24
-
-
Save gr0uch/ec5937b976be558e2ac3 to your computer and use it in GitHub Desktop.
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
/** | |
* Generate an ASCII password with a given length. | |
* | |
* @param {Number} [length] - Length of password, defaults to 18. | |
* @return {String} | |
*/ | |
export default function generatePassword (length = 18) { | |
return String.fromCharCode(...Array.apply(null, Array(length)) | |
// Allow all ASCII characters that can be input via a standard US keyboard, | |
// except for the space character. | |
.map(x => Math.floor(Math.random() * 93 + 33))) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment