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/UserConfig.cs |   46 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 46 insertions(+), 0 deletions(-)

diff --git a/Crabtree/SmartHome/HDL/Operation/UserConfig.cs b/Crabtree/SmartHome/HDL/Operation/UserConfig.cs
index 93db11b..a052da0 100644
--- a/Crabtree/SmartHome/HDL/Operation/UserConfig.cs
+++ b/Crabtree/SmartHome/HDL/Operation/UserConfig.cs
@@ -154,6 +154,10 @@
             set {
                 currentRegion = value;
                 CheckIfNeedGetMasterAccountToken ();
+                //鍒囨崲浣忓畢 璁剧疆鏈湴鍔犲瘑Key
+                SetLocalEncryptKey ();
+
+
             }
             get {
                 if (currentRegion == null) {
@@ -256,6 +260,48 @@
 
         public List<string> RometoUserInfoKeys = new List<string> ();
 
+
+        /// <summary>
+        /// 鏈湴閫氫俊鍔犲瘑Key
+        /// </summary>
+        public string LocalEncryptKey = string.Empty;
+
+        /// <summary>
+        /// 鏄惁鍔犲瘑
+        /// </summary>
+        public bool IsLocalEncrypt = false;
+        /// <summary>
+        /// 璁剧疆涓洪粯璁ゅ姞瀵嗭紝骞惰绠楀姞瀵咾ey
+        /// </summary>
+        private void SetLocalEncryptKey ()
+        {
+            if (currentRegion != null) {
+                IsLocalEncrypt = true;
+                GenerateLocalEncryptionKey ();
+                //LocalEncryptKey = CommonPage.MyEncodingUTF8.GetString (GenerateLocalEncryptionKey ());
+            }
+        }
+
+        /// <summary>
+        /// 鑾峰彇16浣嶇殑key byte []
+        /// </summary>
+        /// <returns></returns>
+        public byte [] GenerateLocalEncryptionKey ()
+        {
+            byte [] aseKey = new byte [16];
+            try {
+                //鐢熸垚鍔犲瘑Key
+                byte [] homeId =  System.Text.Encoding.ASCII.GetBytes (currentRegion.Id);
+                Array.Copy (homeId, 0, aseKey, 0, 16 < homeId.Length ? 16 : homeId.Length);
+                LocalEncryptKey = System.Text.Encoding.ASCII.GetString (aseKey);
+                return aseKey;
+
+            } catch {
+                return aseKey;
+            }
+
+        }
+
         public string MasterAccountToken = "";
         public string MasterAccountRequestBaseUrl = "";
         /// <summary>

--
Gitblit v1.8.0