PasswordGenerator
PasswordGenerator copied to clipboard
Incorrect password created when using "false" for parameters
Hi. First, thanks for sharing your solution:) I was looking into your Generate method. I have suggestion for improvement if you want. All your parameters are marked with word "require" so from this perspective it's working correctly. Let me explain what I have in mind. So if you would want to use those parameter as condition to include or not include specific chars (like I want password without digits) than "for" loop will return wrong password for you. In line: string rcs = randomChars[rand.Next(0, randomChars.Length)]; you are going back to randomChars which contains all chars(including in this sample digits). If you would like to improve your method than I would suggest to add additional property which will held only chars filtered by you parameters and then use this property to populates rcs. This way you will be able to produce password with "required" chars and password which will not have specific chars on your wish. Cheers
Take a look at the excludeNonRequiredChars
parameter here: https://github.com/peterbozso/IdentityPasswordGenerator/blob/main/src/IdentityPasswordGenerator/IPasswordGenerator.cs