lcl před 1 rokem
rodič
revize
63324c5883
1 změnil soubory, kde provedl 32 přidání a 1 odebrání
  1. 32 1
      Controllers/HomeController.cs

+ 32 - 1
Controllers/HomeController.cs

@@ -10,6 +10,7 @@ using MySystem.PxcModels;
 using System.Threading;
 using Library;
 using LitJson;
+using System.Security.Cryptography;
 
 namespace MySystem.Controllers
 {
@@ -191,7 +192,37 @@ namespace MySystem.Controllers
             // result += SetDepositPostService.Instance.LDFeeRate("110000004032435", "0.0063", 10, 3) + "\n\n";
             // result += SetDepositPostService.Instance.LDFeeRate("110000004008674", "0.0063", 11, 3) + "\n\n";
 
-            return result;
+            string str = "{\"password\":\"admin\",\"phone\":\"1300000000\"}";
+            string resultJson = Encrypt(str, "CBTU1dD4Kd5pyiGWTsI10jRQ3SvKusSV", "DYgjCEIMVrj2W9xN");
+            string ApiResponse = function.GetWebRequest("?value=" + System.Web.HttpUtility.UrlEncode(resultJson));
+
+            return ApiResponse;
+        }
+
+        public string Encrypt(string plainText, string keyString, string ivString)
+        {
+            byte[] cipherData;
+            Aes aes = Aes.Create();
+            aes.Key = System.Text.Encoding.UTF8.GetBytes(keyString);
+            aes.IV = System.Text.Encoding.UTF8.GetBytes(ivString);
+            aes.Mode = CipherMode.CBC;
+            aes.Padding = PaddingMode.PKCS7;
+            ICryptoTransform cipher = aes.CreateEncryptor(aes.Key, aes.IV);
+
+            using (System.IO.MemoryStream ms = new System.IO.MemoryStream())
+            {
+                using (CryptoStream cs = new CryptoStream(ms, cipher, CryptoStreamMode.Write))
+                {
+                    using (System.IO.StreamWriter sw = new System.IO.StreamWriter(cs))
+                    {
+                        sw.Write(plainText);
+                    }
+                }
+
+                cipherData = ms.ToArray();
+            }
+
+            return Convert.ToBase64String(cipherData);
         }