Github

Password Generator Algorithm

This dynamic password generator takes the options that are set and adds those to a list. It then picks a random index, adds that character to the password result. Continue to do this and you have your password.

var length = 50;

var combos = {
   numbers: '0123456789',
   lowercase: 'abcdefghijklmnopqrstuvwxyz',
   uppercase: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
   symbols: '!\'"#$%&()*+,-./:;<=>[email protected][\\]^_`{|}~'
};

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
});

You can visit the website: https://andre.gg/passgen

Comments