Explorar o código

增加了输出解密后的日志,优化了没有加密字段时也能正常运行

chenjiangqun %!s(int64=2) %!d(string=hai) anos
pai
achega
606584d818

+ 4 - 3
FactoryTool_CShare/Business/V2Method.cs

@@ -150,7 +150,7 @@ namespace MOKA_Factory_Tools
                 mid.clienttype = jObject["clientType"].Value<string>();
                 mid.host = jObject["host"].Value<string>();
                 mid.whiteType = jObject["whiteType"].Value<string>();
-                mid.aesEncrypt = jObject["aesEncrypt"].Value<string>();
+                mid.aesEncrypt = jObject["aesEncrypt"] == null ? false : jObject["aesEncrypt"].Value<string>().Equals("yes", StringComparison.OrdinalIgnoreCase);
                 object a = jObject["rokuCustomer"];
                 if (jObject["rokuCustomer"].ToString().Length > 0)
                 {
@@ -213,7 +213,7 @@ namespace MOKA_Factory_Tools
                     if (code == "0")
                     {
                         //需要解密
-                        if (midList != null && midList.aesEncrypt.Equals("yes", StringComparison.InvariantCultureIgnoreCase))
+                        if (midList != null && midList.aesEncrypt)
                         {
                             AES_DES Aes = new AES_DES();
                             //data解密
@@ -221,6 +221,7 @@ namespace MOKA_Factory_Tools
                             string key = AES_DES.AESKey;
                             byte[] IV = AES_DES.AESIV;
                             string str = AES_DES.DecryptStringFromBytes_Aes(plainText, key, IV);
+                            Log.WriteInfoLog("解密后:" + str);
                             jObject["data"] = str;
                         }
                         Dictionary<string, string> data = JsonConvert.DeserializeObject<Dictionary<string, string>>(jObject["data"].ToString());
@@ -634,7 +635,7 @@ namespace MOKA_Factory_Tools
                 timeout = 5000;
             HttpHelper http = new HttpHelper();
             //需要加密上报的话 
-            if (midList != null && midList.aesEncrypt.Equals("yes", StringComparison.InvariantCultureIgnoreCase))
+            if (midList != null && midList.aesEncrypt)
             {
               AES_DES AES_DES = new AES_DES();
               string key = AES_DES.AESKey;

+ 1 - 1
FactoryTool_CShare/Models/StructList.cs

@@ -30,7 +30,7 @@ namespace MOKA_Factory_Tools
         public string whiteType { get; set; }
         public RokuCustomer rokuCustomer { get; set; }
         public Dictionary <string,string> keytype { get; set; }
-        public string aesEncrypt { get; set; }
+        public bool aesEncrypt { get; set; } = false;
     }
 
     public class RokuData