This script basically creates a table of ascii values for valid password characters based on whatever the valid character rules are, then randomly generates numbers. If the random number matches a value in the table, it is appended to the password string, otherwise another number is generated.
Complexity rules are applied as the string is generated and a final check is performed before the password is presented.
Script is ready to run, and will return a password of 8 to 16 characters with the following characteristics:
- at least 1 upper case letter
- at least 1 lower case letter
- at least 1 number
- at least 1 special character
Rules are easily modifiable, script is completely commented.