/// <summary> /// AES 解密 /// </summary> /// <param name="str"></param> /// <param name="key"></param> /// <returns></returns> public static string AesDecrypt_FromHexStr(string str, byte[] btkey) { if (string.IsNullOrEmpty(str)) { return(null); } Byte[] toEncryptArray = StringToByte.strToToHexByte(str); System.Security.Cryptography.RijndaelManaged rm = new System.Security.Cryptography.RijndaelManaged { Key = btkey, 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)); }
public byte[] ToHex(string input) { return(StringToByte.strToToHexByte(input)); }