

The remaining slots are filled using the same strategy for the previous character sets.ĭescription of password complexity: Password complexity is usually talked about in bits of entropy. All the characters are added to a single array. Random distribution for the remaining characters: After the minimum values have been set, we want to make the rest of the characters random across all character sets.We choose the minimum amount of random values from each character set and then move on. Guaranteeing minimum characters of each type are set: We simply carve out the minimum character amount first.Random characters: In addRandomCharacters, a random index from the character index we're using is chosen and added to the pw array.

As we call addRandomCharacters, it removes an index randomly and we use the removed index to populate the array. Random character order for the password: All the indexes of the pw char array are added to the remainingIndexes array.Randomness of Random: We're using SecureRandom which is backed by a cryptographically strong PRNG, rather than the Random class which is not.The main bits for the actual password generation: PasswordCharacterSet Min Characters: The min characters to use for this character set.PasswordCharacterSet: It is assumed that all PasswordCharacterSets passed into PasswordGenerator consist of unique character sets, if not, the random characters will have a skew towards the duplicates.


It provides the required functionality needed in its PasswordGenerator class.
