Generate random passwords with conditions

I am working on a random password generator to create passwords that meet certain conditions, including, but not necessarily:

  • minimum length: must contain at least 8 characters
  • lowercase letters: must contain lowercase letters (selected from the set to avoid problems with characters that might be mistaken as numbers)
  • uppercase letters: must contain uppercase letters (again, selected from the set)
  • digits: must contain numbers

What would be the best algorithmic approach to ensure that the generated password matches all of these?

I'm not looking for a complete solution, I need only a few good ideas and recommendations.

+5
source share
3 answers

1) randomly generates the number L, which will be the exact length of your password. Namely, generate so that it is greater than 8
2) randomly generate the number LL, which will be the number of letters in lowercase. LC must be in the range [1.. L-2]
3) randomly generates the LU number for the upper case. Must be in the range [1..L-LL-1]
4) LD = L-LL-LU the number of uppercase digits
5) randomly generates the lowercase letters LL, the uppercase letters LU and the digits LD and save them in a list (array)
6) Random array move

Hth

+6
source
  • , a - z, A - Z, 0 - 9 ( , )
  • 8
  • , ,
  • ,

.

+3

, . , :

  • ()
  • (: || || )
  • , , .

6 .

EDIT: , , , . !

+1

All Articles