I would very much like to see the following overloaded method added to the Chilkat.Prng class:
The reason is obviously that the current method
gives the option to require upper- and lower-case characters in the generated string, but does not have an option limit to only upper- or lower-case characters. If upperAndLowercase is set to false, the generated string may contain both upper- and lower-case characters, but it is not guaranteed to have both. I want to have an option similar to that of the RandomString() method, where I can specify explicitly to include or exclude each case. |
After some testing and consideration, it may not be as simple as that. At first I read e.g. the argument bool mustIncludeDigit as if it is set to false, the generated string will not contain any digit. But what it really means is true = required, false = optional (not excluded). That however is easy to solve by adding all digits to the argument string excludeChars.
And after even more testing it appears that the method already appears to handle what I am requesting. Well sort of, because there appears to be a bug in this method that randomly creates string that does not satisfy the criteria, but a simple retry can be used as workaround for now.
Say I want only lower-case characters in the generated string, I simply call RandomPassword(8, false, false, "", "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ"). This way no symbols are used, digits now required and excluded, upper-case chars not required and excluded.