加密方式 AES-CBC-128
将解密方法改成如下
public string Decrypt(string toDecrypt, string key) { SymmetricAlgorithm des = Rijndael.Create(); byte[] inputByteArray = Encoding.UTF8.GetBytes(toDecrypt); des.Key = Encoding.UTF8.GetBytes(key); des.IV = des.Key; des.Mode = CipherMode.CBC; des.Padding = PaddingMode.PKCS7; ICryptoTransform cTransform = des.CreateEncryptor(); return UTF8Encoding.UTF8.GetString(cTransform.TransformFinalBlock(inputByteArray, 0, inputByteArray.Length)); }