码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2017-01-07 00:55:47      阅读:229      评论:0      收藏:0      [点我收藏+]

标签:rds   长度   ack   string   pass   str   match   word   stat   

密码强度要求:

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 }

 

 

 

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

标签:rds   长度   ack   string   pass   str   match   word   stat   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!