Roc 5 vuotta sitten
vanhempi
sitoutus
001f0eb1c4

+ 6 - 1
src/Essensoft.AspNetCore.Payment.Alipay/Utility/AlipaySignature.cs

@@ -22,7 +22,7 @@ namespace Essensoft.AspNetCore.Payment.Alipay.Utility
             {
                 if (!string.IsNullOrEmpty(iter.Value))
                 {
-                    sb.Append(iter.Key).Append("=").Append(iter.Value).Append("&");
+                    sb.Append(iter.Key).Append('=').Append(iter.Value).Append('&');
                 }
             }
 
@@ -54,6 +54,11 @@ namespace Essensoft.AspNetCore.Payment.Alipay.Utility
             return AES.Encrypt(data, encyptKey, AES_IV, CipherMode.CBC, PaddingMode.PKCS7);
         }
 
+        public static string AESDencrypt(string data, string encyptKey)
+        {
+            return AES.Decrypt(data, encyptKey, AES_IV, CipherMode.CBC, PaddingMode.PKCS7);
+        }
+
         private static byte[] InitIv(int blockSize)
         {
             var iv = new byte[blockSize];

+ 2 - 2
src/Essensoft.AspNetCore.Payment.Security/AES.cs

@@ -25,7 +25,7 @@ namespace Essensoft.AspNetCore.Payment.Security
 
             using (var aes = Aes.Create())
             {
-                aes.Key = Encoding.UTF8.GetBytes(key);
+                aes.Key = Convert.FromBase64String(key);
                 aes.IV = iv;
                 aes.Mode = cipherMode;
                 aes.Padding = paddingMode;
@@ -57,7 +57,7 @@ namespace Essensoft.AspNetCore.Payment.Security
 
             using (var aes = Aes.Create())
             {
-                aes.Key = Encoding.UTF8.GetBytes(key);
+                aes.Key = Convert.FromBase64String(key);
                 aes.IV = iv;
                 aes.Mode = cipherMode;
                 aes.Padding = paddingMode;