From adee7a71ba7ab1b63cab63381dfe1846437853d6 Mon Sep 17 00:00:00 2001
From: wzp <2040239371@qq.com>
Date: 星期四, 02 三月 2023 17:37:05 +0800
Subject: [PATCH] 增加分销商配置

---
 web/Common/DESEncrypt.cs |   91 ++++++++++++++++++++++++---------------------
 1 files changed, 49 insertions(+), 42 deletions(-)

diff --git a/web/Common/DESEncrypt.cs b/web/Common/DESEncrypt.cs
index 4f8109c..3582b13 100644
--- a/web/Common/DESEncrypt.cs
+++ b/web/Common/DESEncrypt.cs
@@ -6,51 +6,58 @@
 
 namespace Common
 {
-  public class DESEncrypt
-  {
-    public static string Encrypt(string Text)
-    {
-      return DESEncrypt.Encrypt(Text, "litianping");
-    }
 
-    public static string Encrypt(string Text, string sKey)
+    public class DESEncrypt
     {
-      DESCryptoServiceProvider cryptoServiceProvider = new DESCryptoServiceProvider();
-      byte[] bytes = Encoding.Default.GetBytes(Text);
-      cryptoServiceProvider.Key = Encoding.ASCII.GetBytes(FormsAuthentication.HashPasswordForStoringInConfigFile(sKey, "md5").Substring(0, 8));
-      cryptoServiceProvider.IV = Encoding.ASCII.GetBytes(FormsAuthentication.HashPasswordForStoringInConfigFile(sKey, "md5").Substring(0, 8));
-      MemoryStream memoryStream = new MemoryStream();
-      CryptoStream cryptoStream = new CryptoStream((Stream) memoryStream, cryptoServiceProvider.CreateEncryptor(), CryptoStreamMode.Write);
-      cryptoStream.Write(bytes, 0, bytes.Length);
-      cryptoStream.FlushFinalBlock();
-      StringBuilder stringBuilder = new StringBuilder();
-      foreach (byte num in memoryStream.ToArray())
-        stringBuilder.AppendFormat("{0:X2}", (object) num);
-      return stringBuilder.ToString();
-    }
+        //鍔犲瘑涓�
+        //public static string encryptStr = "litianping";
+        public static string encryptStr = "abcDEF123@$@";
 
-    public static string Decrypt(string Text)
-    {
-      return DESEncrypt.Decrypt(Text, "litianping");
-    }
+        public static string Encrypt(string Text)
+        {
+            return DESEncrypt.Encrypt(Text, encryptStr);
+        }
 
-    public static string Decrypt(string Text, string sKey)
-    {
-      DESCryptoServiceProvider cryptoServiceProvider = new DESCryptoServiceProvider();
-      int length = Text.Length / 2;
-      byte[] buffer = new byte[length];
-      for (int index = 0; index < length; ++index)
-      {
-        int num = Convert.ToInt32(Text.Substring(index * 2, 2), 16);
-        buffer[index] = (byte) num;
-      }
-      cryptoServiceProvider.Key = Encoding.ASCII.GetBytes(FormsAuthentication.HashPasswordForStoringInConfigFile(sKey, "md5").Substring(0, 8));
-      cryptoServiceProvider.IV = Encoding.ASCII.GetBytes(FormsAuthentication.HashPasswordForStoringInConfigFile(sKey, "md5").Substring(0, 8));
-      MemoryStream memoryStream = new MemoryStream();
-      CryptoStream cryptoStream = new CryptoStream((Stream) memoryStream, cryptoServiceProvider.CreateDecryptor(), CryptoStreamMode.Write);
-      cryptoStream.Write(buffer, 0, buffer.Length);
-      cryptoStream.FlushFinalBlock();
-      return Encoding.Default.GetString(memoryStream.ToArray());
+        public static string Encrypt(string Text, string sKey)
+        {
+            DESCryptoServiceProvider cryptoServiceProvider = new DESCryptoServiceProvider();
+            byte[] bytes = Encoding.Default.GetBytes(Text);
+            //c#鐨凞ES鍔犲瘑鏄痥ey涓�8浣�
+            cryptoServiceProvider.Key = Encoding.ASCII.GetBytes(FormsAuthentication.HashPasswordForStoringInConfigFile(sKey, "md5").Substring(0, 8));
+            cryptoServiceProvider.IV = Encoding.ASCII.GetBytes(FormsAuthentication.HashPasswordForStoringInConfigFile(sKey, "md5").Substring(0, 8));
+            MemoryStream memoryStream = new MemoryStream();
+            CryptoStream cryptoStream = new CryptoStream((Stream)memoryStream, cryptoServiceProvider.CreateEncryptor(), CryptoStreamMode.Write);
+            cryptoStream.Write(bytes, 0, bytes.Length);
+            cryptoStream.FlushFinalBlock();
+            StringBuilder stringBuilder = new StringBuilder();
+            foreach (byte num in memoryStream.ToArray())
+                stringBuilder.AppendFormat("{0:X2}", (object)num);
+            return stringBuilder.ToString();
+        }
+
+        public static string Decrypt(string Text)
+        {
+            return DESEncrypt.Decrypt(Text, encryptStr);
+        }
+
+        public static string Decrypt(string Text, string sKey)
+        {
+            DESCryptoServiceProvider cryptoServiceProvider = new DESCryptoServiceProvider();
+            int length = Text.Length / 2;
+            byte[] buffer = new byte[length];
+            for (int index = 0; index < length; ++index)
+            {
+                int num = Convert.ToInt32(Text.Substring(index * 2, 2), 16);
+                buffer[index] = (byte)num;
+            }
+            //c#鐨凞ES鍔犲瘑鏄痥ey涓�8浣�
+            cryptoServiceProvider.Key = Encoding.ASCII.GetBytes(FormsAuthentication.HashPasswordForStoringInConfigFile(sKey, "md5").Substring(0, 8));
+            cryptoServiceProvider.IV = Encoding.ASCII.GetBytes(FormsAuthentication.HashPasswordForStoringInConfigFile(sKey, "md5").Substring(0, 8));
+            MemoryStream memoryStream = new MemoryStream();
+            CryptoStream cryptoStream = new CryptoStream((Stream)memoryStream, cryptoServiceProvider.CreateDecryptor(), CryptoStreamMode.Write);
+            cryptoStream.Write(buffer, 0, buffer.Length);
+            cryptoStream.FlushFinalBlock();
+            return Encoding.Default.GetString(memoryStream.ToArray());
+        }
     }
-  }
 }

--
Gitblit v1.9.1