Why is this string not equal when it is decrypted a second time with AesCryptoServiceProvider?
问题 I'm having trouble with encryption and decryption of text in C# (VS2012, .NET 4.5). Specifically, When I encrypt and subsequently decrypt a string, the output is not the same as the input. However, bizarrely, if I copy the encrypted output and hardcode it as a string literal, decryption works. The following code sample illustrates the problem. What am I doing wrong? var key = new Rfc2898DeriveBytes("test password", Encoding.Unicode.GetBytes("test salt")); var provider = new