Hii all!!
Well i want to know about how to check for the password entered by the user in a textbox??
When a user enters some characters in textbox, i want to show a label which will tell about the strength of password, that is it strong, weak , poor...
can any one suggest me some code..
I had googled for it.. & found a class file, but on building that class file an error is occuring..
Errors are:
- Cannot implicitly convert type 'System.Text.RegularExpressions.Match' to 'bool'
- Operator '&&' cannot be applied to operands of type 'System.Text.RegularExpressions.Match' and 'System.Text.RegularExpressions.Match'
the class file is here::---
public class PasswordAdvisor
{
enum PasswordScore
{
Blank = 0,
VeryWeak = 1,
Weak = 2,
Medium = 3,
Strong = 4,
VeryStrong = 5
}
public static PasswordScore CheckStrength(string password)
{
int score = 1;
if (password.Length < 1)
return PasswordScore.Blank;
if (password.Length < 4)
return PasswordScore.VeryWeak;
if (password.Length >= 6)
score++;
if (password.Length >= 12)
score++;
if (Regex.Match(password, @"/\d+/", RegexOptions.ECMAScript))
score++;
if (Regex.Match(password, @"/[a-z]/", RegexOptions.ECMAScript) &&
Regex.Match(password, @"/[A-Z]/", RegexOptions.ECMAScript))
score++;
if (Regex.Match(password, @"/.[!,@,#,$,%,^,&,*,?,_,~,-,£,(,)]/", RegexOptions.ECMAScript))
score++;
return (PasswordScore)score;
}
}