Skip to content

Incorrect password created when using "false" for parametersΒ #2

@suszi88

Description

@suszi88

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions