密码强度要求:

1、密码长度至少为8个字符

2、至少要有一个大写英文或者小写字母

3、最少包含一个数字

备注:该方法也可以拆成4个if判断,可以针对不同的情况,对注册客户进行提示。

 1 public static bool PasswordStrength(string password)
 2 {
 3     if (password.Length <8)
 4     {
 5         return false;
 6     }
 7     if (0 - Convert.ToInt32(Regex.IsMatch(password, "[a-z]")) 
 8           - Convert.ToInt32(Regex.IsMatch(password, "[A-Z]")) 
 9           - Convert.ToInt32(Regex.IsMatch(password, "\\d")) 
10           - Convert.ToInt32(Regex.IsMatch(password, ".{10,}")) <= -2)
11     {
12         return true;
13     }
14     else
15     {
16         return false;
17     }
18 }

 

 

 

相关文章:

  • 2021-11-03
  • 2021-10-17
  • 2021-09-20
  • 2021-10-22
  • 2022-12-23
  • 2021-11-10
  • 2022-12-23
猜你喜欢
  • 2021-11-01
  • 2021-09-02
  • 2022-02-11
  • 2021-12-03
  • 2021-10-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案