Browse Source

密码验证

“hujiajun” 6 months ago
parent
commit
255bd1f110

+ 109 - 0
Assets/ChangePass.cs

@@ -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+)*$";//验证Email地址
+    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}$";//验证身份证号(15位或18位数字)
+    /// <summary>
+    /// 正则表达式判断
+    /// </summary>
+    /// <param name="str">输入内容</param>
+    /// <param name="regularExpression">正则表达式</param>
+    /// <returns>是否符合输入格式</returns>
+    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);
+    }
+
+    //不能相同字符(如111、aaa)连续3位或3位以上
+    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);
+    }
+
+
 }

+ 11 - 11
Assets/DataManager.cs

@@ -990,17 +990,6 @@ public static string Md5(string str)
 
 
 
-            LineChartSeriesData lc = new LineChartSeriesData();
-            lc.name = "今日";
-            lc.values = new List<float>();
-            for (int i = 0; i < datamsg["data"][ "today_info"].Count; i++)
-            {
-                data.xdata.Add(datamsg["data"]["today_info"][i]["time"].ToString().Split(' ')[1]);
-                lc.values.Add(float.Parse(datamsg["data"]["today_info"][i]["value"].ToString()));
-            }
-            data.sdata.Add(lc);
-
-
             LineChartSeriesData lc2 = new LineChartSeriesData();
             lc2.name = "昨日";
             lc2.values = new List<float>();
@@ -1010,6 +999,17 @@ public static string Md5(string str)
             }
             data.sdata.Add(lc2);
 
+
+
+            LineChartSeriesData lc = new LineChartSeriesData();
+            lc.name = "今日";
+            lc.values = new List<float>();
+            for (int i = 0; i < datamsg["data"][ "today_info"].Count; i++)
+            {
+                data.xdata.Add(datamsg["data"]["today_info"][i]["time"].ToString().Split(' ')[1]);
+                lc.values.Add(float.Parse(datamsg["data"]["today_info"][i]["value"].ToString()));
+            }
+            data.sdata.Add(lc);
             callback.Invoke(data);
 
         }));

+ 26 - 3
Assets/DianLiJianKongManager.cs

@@ -141,12 +141,31 @@ public class DianLiJianKongManager : UpdateManager
                 break;
             }
 
-        }
+        }   
+
         DataManager.Instance.GetTwoWsdTb(chooseroom, jiguiindex, (data) => {
             for (int i = 0; i < data.Count; i++)
             {
-
-                setLineData(lcs[i], data[i]);
+                if(data[i].sdata.Count>0)
+                {
+                    for   (int j =0;j<data[i].sdata.Count;j++)
+                    {
+                        if(data[i].sdata[j].values.Count>0)
+                        {
+                            Debug.Log(data[i].sdata[j].values[0]);
+
+                            lcs[i].gameObject.SetActive(true);
+                            break;
+                        }
+                        else
+                        {
+                            lcs[i].gameObject.SetActive(false);
+
+                        }
+                    }
+                    setLineData(lcs[i], data[i]);
+                }
+                
             }
         });
         
@@ -171,6 +190,10 @@ public class DianLiJianKongManager : UpdateManager
 
     private void OnEnable()
     {
+        for (int i = 0; i < lcs.Count; i++)
+        {
+            lcs[i].gameObject.SetActive(false);
+        }
         StartCoroutine(show());
     }
 

File diff suppressed because it is too large
+ 45 - 3
Assets/Scenes/16-9.unity


File diff suppressed because it is too large
+ 1 - 43
Assets/Scenes/16-9green.unity


File diff suppressed because it is too large
+ 44 - 2
Assets/Scenes/32-9.unity


File diff suppressed because it is too large
+ 42 - 0
Assets/Scenes/32-9green.unity


File diff suppressed because it is too large
+ 0 - 42
Assets/Scenes/Main.unity


+ 6 - 0
Assets/createzhanghao.cs

@@ -88,6 +88,12 @@ public class createzhanghao : MonoBehaviour
 
     void cgyc()
     {
+         accinput.text="";
+       nameinput.text="";
+      deptinput.text="";
+        notesinput.text="";
+       positioninput.text="";
+        inputpass.text="";
         cg.SetActive(false);
         this.gameObject.SetActive(false);
         one.SetActive(true);

+ 3 - 3
ProjectSettings/ProjectSettings.asset

@@ -759,11 +759,11 @@ PlayerSettings:
   apiCompatibilityLevel: 6
   activeInputHandler: 0
   windowsGamepadBackendHint: 0
-  cloudProjectId: 2c168d25-511a-41c5-bd75-83668e930527
+  cloudProjectId: 
   framebufferDepthMemorylessMode: 0
   qualitySettingsNames: []
-  projectName: wxMini
-  organizationId: aaaaaaff
+  projectName: 
+  organizationId: 
   cloudEnabled: 0
   legacyClampBlendShapeWeights: 0
   hmiLoadingImage: {fileID: 0}

BIN
test2/test/Build/test.data.unityweb


BIN
test2/test/Build/test.framework.js.unityweb


BIN
test2/test/Build/test.symbols.json.unityweb


BIN
test2/test/Build/test.wasm.unityweb


Some files were not shown because too many files changed in this diff