|
@@ -1,3 +1,4 @@
|
|
|
+using System;
|
|
|
using System.Collections;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Text.RegularExpressions;
|
|
@@ -80,6 +81,55 @@ public class ChangePass : MonoBehaviour
|
|
|
{
|
|
|
msg = "密码必须大于8位";
|
|
|
}
|
|
|
+ else if(ct>=3)
|
|
|
+ {
|
|
|
+ bool hasConsecutiveNumbersOrLetters = checkSame(pass);
|
|
|
+
|
|
|
+ if (hasConsecutiveNumbersOrLetters)
|
|
|
+ {
|
|
|
+ ct=0;
|
|
|
+ msg = "字符串包含连续的数字或字母。";
|
|
|
+ }
|
|
|
+ if(pass.Contains("oper")||pass.Contains("admin"))
|
|
|
+ {
|
|
|
+ ct=0;
|
|
|
+ msg = "严禁在口令中包含英文单词或拼音";
|
|
|
+
|
|
|
+ }
|
|
|
+ if(pass.Contains("ftp@ftp.net"))
|
|
|
+ {
|
|
|
+ ct=0;
|
|
|
+ msg = "严禁使用系统或应用的默认口令";
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ bool isTwoAdjacentKeys = IsTwoAdjacentKeys(pass);
|
|
|
+
|
|
|
+ if(isTwoAdjacentKeys)
|
|
|
+ {
|
|
|
+
|
|
|
+ ct=0;
|
|
|
+ msg = "位于键盘相邻位置的字符超过2位";
|
|
|
+ }
|
|
|
+ bool containsSimilar = ContainsSimilarString(pass);
|
|
|
+
|
|
|
+ if(containsSimilar)
|
|
|
+ {
|
|
|
+
|
|
|
+ ct=0;
|
|
|
+ msg = "含有与账号名、主机名、系统名、厂商名相同或相似的字符串";
|
|
|
+ }
|
|
|
+ bool isphone = NameJudgeFlage(pass,phoneNumber);
|
|
|
+ bool isidCard = NameJudgeFlage(pass,idCard);
|
|
|
+
|
|
|
+ if(isphone||isidCard)
|
|
|
+ {
|
|
|
+ ct=0;
|
|
|
+ msg = "严禁含有与局房、人员姓名、生日、证件号码、电话号码、手机号码及门牌号码等";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
passcheck p= new passcheck();
|
|
|
p.ct = ct;
|
|
|
p.msg=msg;
|
|
@@ -132,10 +182,69 @@ public class ChangePass : MonoBehaviour
|
|
|
}
|
|
|
|
|
|
|
|
|
+ }
|
|
|
+ private static readonly Regex _noConsecutiveNumbersRegex = new Regex(@"\d{3,}|[a-z]{3,}|[A-Z]{3,}");
|
|
|
+
|
|
|
+ public static bool IsValidPassword(string password)
|
|
|
+ {
|
|
|
+ return _noConsecutiveNumbersRegex.IsMatch(password);
|
|
|
}
|
|
|
void savecloes()
|
|
|
{
|
|
|
savesuccess.SetActive(false);
|
|
|
MainCenterManager.Instance.showMain();
|
|
|
}
|
|
|
+ static string NameJudge = "^[\u4e00-\u9fa5a-zA-Z0-9]{1,20}$";
|
|
|
+ static string local = @"^[a-zA-Z]:((\\+[^\/:*?""<>|]+)+)\s*$";
|
|
|
+ static string expression = "([hH][tT]{2}[pP]://|[hH][tT]{2}[pP][sS]://|[wW]{3}.|[wW][aA][pP].|[fF][tT][pP].|[fF][iI][lL][eE].)[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]";
|
|
|
+ static string email = @"^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$";
|
|
|
+ static string phoneNumber = @"^1(3[0-9]|4[5-9]|5[0-35-9]|6[2567]|7[0-8]|8[0-9]|9[0-35-9])\d{8}$";
|
|
|
+ static string idCard = @"^\d{15}|\d{18}$";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ public static bool NameJudgeFlage(string str, string regularExpression)
|
|
|
+ {
|
|
|
+ Regex reg = new Regex(regularExpression);
|
|
|
+ return reg.IsMatch(str);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private static readonly string[] adjacentKeys = new string[]
|
|
|
+ {
|
|
|
+ "qwertyuiop", "asdfghjkl", "zxcvbnm",
|
|
|
+ "qaz", "wsx", "edc", "rfv", "tgb", "nhy", "ujm", "ik", "ol", "p;",
|
|
|
+ "12", "34", "56", "78", "90",
|
|
|
+ "QWERTYUIOP", "ASDFGHJKL", "ZXCVBNM",
|
|
|
+ "QAZ", "WSX", "EDC", "RFV", "TGB", "NHY", "UJM", "IK", "OL", "P;",
|
|
|
+ "12", "34", "56", "78", "90","ab","cd","ef","gh","ij","kl","mn","op","qr","st","uv","wx","yz"
|
|
|
+ };
|
|
|
+
|
|
|
+
|
|
|
+ private static readonly string pattern = string.Join("|", adjacentKeys).Replace("q", "[qQ]").Replace("w", "[wW]").Replace("s", "[sS]").Replace("d", "[dD]");
|
|
|
+
|
|
|
+ public static bool IsTwoAdjacentKeys(string input)
|
|
|
+ {
|
|
|
+ return Regex.IsMatch(input, pattern);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public static bool checkSame(string str) {
|
|
|
+ Regex _checkSame = new Regex(@"/(\w)\1{3,}/");
|
|
|
+ return _checkSame.IsMatch(str);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private static readonly string pattern2 = @"(账号名|主机名|系统名|厂商名)";
|
|
|
+
|
|
|
+
|
|
|
+ public static bool ContainsSimilarString(string input)
|
|
|
+ {
|
|
|
+ return Regex.IsMatch(input, pattern2, RegexOptions.IgnoreCase);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|