How do I verify in C# that the password contains at least X uppercase letters and at least Y numbers, and the entire string is longer than Z?
Thanks.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Password Strength:
First, I would read up on password strength, and double-check your policy to make sure you were doing the right thing (I couldn’t tell you off hand):
Then I’d check other questions:
Then I’d get down to business.
Implementation:
You could use Linq:
You could use also regular expressions (which might be a good option to allow you to plug in more complicated validations in the future):
Or you could mix and match them.
If you had to do this multiple times, you could reuse the
Regexinstances by building a class: