From 4a61a132ce09b1fd42fd80fcbff1855bad4c0f48 Mon Sep 17 00:00:00 2001 From: JLChen <551775569@qq.com> Date: 星期三, 15 一月 2020 11:15:24 +0800 Subject: [PATCH] 2020-01-15 1.优化。 --- Crabtree/SmartHome/HDL/Operation/Packet.cs | 46 ++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 42 insertions(+), 4 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..ded4f36 --- 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,8 +57,13 @@ /// </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; } @@ -113,5 +117,39 @@ } return s;// } + + /// <summary> + /// 鏄惁鏈湴 + /// </summary> + public bool IsLocal = true; + + /// <summary> + /// 鏈湴閫氳鏃� 鍔犲瘑妫�娴� + /// </summary> + void EncryptionDetection () { + if (IsLocal) {//鏈湴閫氳 + + if (UserConfig.Instance.IsLocalEncrypt) { + if ("Passord error" == (System.Text.Encoding.ASCII.GetString (Bytes, 14, 13))) { + //缃戝叧杩斿洖锛屽姞瀵嗗瘑鐮乲ey涓嶅 + + return; + } + var messageGet = Shared.Securitys.EncryptionService.AesEncryptPayload (Bytes, UserConfig.Instance.LocalEncryptKey); + Bytes = messageGet; + + + } else { + if ("Locked" == (System.Text.Encoding.ASCII.GetString (Bytes, 14, 6))) { + //缃戝叧宸插姞瀵嗭紝鑷姩鍒囨崲涓哄姞瀵� + UserConfig.Instance.IsLocalEncrypt = true; + } + + } + + } + } + + } -} \ No newline at end of file +} -- Gitblit v1.8.0