Skip to content

Instantly share code, notes, and snippets.

@andrejarrell andrejarrell/passgen.js
Last active Nov 3, 2019

Embed
What would you like to do?
Password generator algorithm created by yours truely https://andre.gg/passgen
var length = 50;
var combos = {
numbers: '0123456789',
lowercase: 'abcdefghijklmnopqrstuvwxyz',
uppercase: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
symbols: '!\'"#$%&()*+,-./:;<=>?@[\\]^_`{|}~'
};
generateCombo = options => {
var combo = '';
for(i=0; i<Object.keys(options).length; i++) {
if (options[Object.keys(options)[i]]) combo += combos[`${Object.keys(combos)[i]}`];
};
return combo;
};
generatePassword = (length, options) => {
var pass = '';
combo = generateCombo(options);
for (x=0; x<length; x++) pass += combo[Math.floor(Math.random() * combo.length)];
console.log(pass);
};
generatePassword(length, {
numbers: true,
lowercase: true,
uppercase: true,
symbols: true
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.