javascript

  • if addNumbers then take random number from range from 1 to ( passwordLength – noOfneededTypes + usedTypeCounter – noOfLowerCharacters – noOfUpperCharacters ).
  • What you need to do is to take at least one random character from each needed array ( upperCharacters , numbers , symbols ) and shuffle it.
  • /\W/.test(pass)) continue; // check symbols if (addNums && !
  • push proper number of random characters from each array ( lowerCharacters , upperCharacters , …
  • Stack Overflow works best with JavaScript enabled

How can I make this random password generator to generate at least one of the components?
Currently, it happens that a number is not included in the generated password, or any of other types is left out. How to make it to generate at least of of the types?

@soiqbot: angularjs random password generator at least one upper, lower, number and special character

How can I make this random password generator to generate at least one of the components? Currently, it happens that a number is not included in the generated password, or any of other types is left out. How to make it to generate at least of of the types?

function randomPass (length, addUpper, addSymbols, addNums) { var lower = “abcdefghijklmnopqrstuvwxyz”; var upper = addUpper ? lower.toUpperCase() : “”; var nums = addNums ? “0123456789” : “”; var symbols = addSymbols ? “!#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~” : “”; var all = lower + upper + nums + symbols; while (true) { var pass = “”; for (var i=0; i

javascript