JLChen
2020-01-15 4a61a132ce09b1fd42fd80fcbff1855bad4c0f48
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>
        /// 设置为默认加密,并计算加密Key
        /// </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>