Skip to content

Instantly share code, notes, and snippets.

@kickboxer
Created June 26, 2015 14:33
Show Gist options
  • Save kickboxer/f71e79bba4cd5be3026e to your computer and use it in GitHub Desktop.
Save kickboxer/f71e79bba4cd5be3026e to your computer and use it in GitHub Desktop.
Generate password
function passGen(charsCount) {
var result = '';
var words = '0123456789qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM';
var max_position = words.length - 1,
position,
i;
for(i = 0; i < charsCount; ++i) {
position = Math.floor (Math.random() * max_position);
result = result + words.substring(position, position + 1);
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment