From 9137222ece9b978eb97b5598f2eee6e070bcf9d6 Mon Sep 17 00:00:00 2001
From: JLChen <551775569@qq.com>
Date: 星期五, 28 二月 2020 15:22:16 +0800
Subject: [PATCH] 2020-02-28 更新

---
 Crabtree/SmartHome/HDL/Operation/Packet.cs |   49 ++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 44 insertions(+), 5 deletions(-)

diff --git a/Crabtree/SmartHome/HDL/Operation/Packet.cs b/Crabtree/SmartHome/HDL/Operation/Packet.cs
old mode 100755
new mode 100644
index e52dc8a..923327a
--- a/Crabtree/SmartHome/HDL/Operation/Packet.cs
+++ b/Crabtree/SmartHome/HDL/Operation/Packet.cs
@@ -3,7 +3,6 @@
 using System.Linq;
 using System.Text;
 
-
 namespace Shared
 {
 	public class Packet
@@ -58,14 +57,15 @@
 		/// </summary>
 		public virtual void Manager ()
 		{
-			//瀵逛簬鎿嶄綔鏁版嵁搴撶殑鏃堕棿姣旇緝闀跨殑锛屽彲浠ュ垱寤哄彟涓�涓嚎绋嬪鐞�
-			if (!"HDLMIRACLE".Equals (System.Text.Encoding.ASCII.GetString (Bytes, 4, 10))) {
+            //鍔犲瘑妫�娴�
+            EncryptionDetection ();
+            //瀵逛簬鎿嶄綔鏁版嵁搴撶殑鏃堕棿姣旇緝闀跨殑锛屽彲浠ュ垱寤哄彟涓�涓嚎绋嬪鐞�
+            if (!"HDLMIRACLE".Equals (System.Text.Encoding.ASCII.GetString (Bytes, 4, 10))) {
 				return;
 			}
 
 			byte subnetID = this.Bytes [17]; //婧愬瓙缃戝彿
 			byte deviceID = this.Bytes [18]; //婧愯澶囧彿
-
 
 			//婧愯澶囩被鍨�
 			int deviceType = this.Bytes [19] * 256 + this.Bytes [20];
@@ -113,5 +113,44 @@
             }
             return s;//
         }
+
+        /// <summary>
+        /// 鏄惁鏈湴
+        /// </summary>
+        public bool IsLocal = true;
+
+        /// <summary>
+        /// 鏈湴閫氳鏃� 鍔犲瘑妫�娴�
+        /// </summary>
+        void EncryptionDetection () {
+            if (IsLocal) {//鏈湴閫氳
+               
+                if (UserConfig.Instance.IsLocalEncrypt) {
+                    if (Bytes.Length == 28) {
+                        var mes = System.Text.Encoding.ASCII.GetString (Bytes, 14, 14);
+                        if ("Password error" == mes) {
+                            //缃戝叧杩斿洖锛屽姞瀵嗗瘑鐮乲ey涓嶅
+                            UserConfig.Instance.EncryptedPasswordCorrect = false;
+                            return;
+                        }
+                    }
+                    var messageGet = Shared.Securitys.EncryptionService.AesDecryptPayload (Bytes, UserConfig.Instance.LocalEncryptKey);
+                    Bytes = messageGet;
+
+                   
+                } else {
+                    if (Bytes.Length == 20) {
+                        var mes = System.Text.Encoding.ASCII.GetString (Bytes, 14, 6);
+                        if ("Locked" == mes) {
+                            //缃戝叧宸插姞瀵嗭紝鑷姩鍒囨崲涓哄姞瀵�
+                            UserConfig.Instance.IsLocalEncrypt = true;
+                        }
+                    }
+                }
+
+            }
+        }
+
+
     }
-}
\ No newline at end of file
+}

--
Gitblit v1.8.0