Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should throw instead of returning "Try again" when a valid password cannot be found #13

Open
rasitha1 opened this issue Feb 5, 2020 · 3 comments

Comments

@rasitha1
Copy link

rasitha1 commented Feb 5, 2020

Can the call to .Next() throw instead of returning a password called "Try again" when a valid password could not be generated in maximumAttempts?

I think it's a big risk to return a string like that as the calling application has no way to know what was returned is not a valid password.

A dedicated exception type would be a bonus.

                password = PasswordIsValid(Settings, password) ? password : "Try again";

Source

@clement128
Copy link

Indeed, you either throw exception or use TryXXX pattern

bool TryGenerate(out string password)

saciervo added a commit to saciervo/PasswordGenerator that referenced this issue Apr 14, 2021
Fixes Issue prjseal#13 - Should throw instead of returning "Try again" when a valid password cannot be found
@saciervo
Copy link

@clement128 good idea, but I decided to go with a dedicated exception type. Mainly because I did not want to break backwards compatibility with this project in my fork.

@Ib01
Copy link

Ib01 commented Jun 30, 2021

I actually don't see why you could not guarantee password generation with every call. you might need to tweak the algorithm but I really cannot fathom any reason why it would not be possible... :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants