首页 > 其他 > 详细

验证密码强度是否符合要求

时间:2017-01-07 00:52:50      阅读:269      评论:0      收藏:0      [点我收藏+]

密码强度要求:

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 }

 

 

 

验证密码强度是否符合要求

原文:http://www.cnblogs.com/sunice/p/6257738.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!