密码验证

/// <summary>
/// 新密码强度策略检验
/// </summary>
/// <param name="str">密码</param>
/// <returns></returns>
private bool CheckPwdNew(string str)
{
bool flag = false;
try
{
var regex = new Regex("^(?![a-zA-Z]+$)(?![A-Z0-9]+$)(?![A-Z\\W_]+$)(?![a-z0-9]+$)(?![a-z\\W_]+$)(?![0-9\\W_]+$)[a-zA-Z0-9\\W_]{8,30}$");//必须包含数字,字母大小写,特殊字符,其中的三种及其以上,且长度大于8小于30
if (regex.IsMatch(str))
flag = true;
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return flag;
}

 

posted @ 2019-02-19 15:24  ~雨落忧伤~  阅读(141)  评论(0编辑  收藏  举报