|
@@ -1055,5 +1055,48 @@ namespace MySystem
|
|
|
|
|
|
|
|
#endregion
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ public string AesEncryptForIv(string str)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (string.IsNullOrEmpty(str)) return null;
|
|
|
|
|
+ Byte[] toEncryptArray = Encoding.UTF8.GetBytes(str);
|
|
|
|
|
+ string key = "CBTU1dD4Kd5pyiGWTsI10jRQ3SvKusSV";
|
|
|
|
|
+ string iv = "DYgjCEIMVrj2W9xN";
|
|
|
|
|
+
|
|
|
|
|
+ System.Security.Cryptography.RijndaelManaged rm = new System.Security.Cryptography.RijndaelManaged
|
|
|
|
|
+ {
|
|
|
|
|
+ Key = Encoding.UTF8.GetBytes(key),
|
|
|
|
|
+ IV = Encoding.UTF8.GetBytes(iv),
|
|
|
|
|
+ Mode = System.Security.Cryptography.CipherMode.CBC,
|
|
|
|
|
+ Padding = System.Security.Cryptography.PaddingMode.PKCS7
|
|
|
|
|
+ };
|
|
|
|
|
+ System.Security.Cryptography.ICryptoTransform cTransform = rm.CreateEncryptor();
|
|
|
|
|
+ Byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length);
|
|
|
|
|
+ return Convert.ToBase64String(resultArray, 0, resultArray.Length);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public string AesDecryptForIv(string str)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (string.IsNullOrEmpty(str)) return null;
|
|
|
|
|
+ byte[] toEncryptArray = Convert.FromBase64String(str);
|
|
|
|
|
+ string key = "CBTU1dD4Kd5pyiGWTsI10jRQ3SvKusSV";
|
|
|
|
|
+ string iv = "DYgjCEIMVrj2W9xN";
|
|
|
|
|
+
|
|
|
|
|
+ System.Security.Cryptography.RijndaelManaged rm = new System.Security.Cryptography.RijndaelManaged
|
|
|
|
|
+ {
|
|
|
|
|
+ Key = Encoding.UTF8.GetBytes(key),
|
|
|
|
|
+ IV = Encoding.UTF8.GetBytes(iv),
|
|
|
|
|
+ Mode = System.Security.Cryptography.CipherMode.ECB,
|
|
|
|
|
+ Padding = System.Security.Cryptography.PaddingMode.PKCS7,
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ System.Security.Cryptography.ICryptoTransform cTransform = rm.CreateDecryptor();
|
|
|
|
|
+ byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length);
|
|
|
|
|
+ return Encoding.UTF8.GetString(resultArray);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|