I\'m having some trouble with the code below. I have a file in a temporary location which is in need of encryption, this function encrypts that data which is then stored at
The KeySize must be specified first. This looks like a bug e.g. this works
using (var aes = new AesManaged())
{
aes.KeySize = 256;
aes.Mode = CipherMode.CBC;
aes.IV = iv;
aes.Key = passwordHash;
aes.Padding = PaddingMode.PKCS7;
but this doesn't
using (var aes = new AesManaged())
{
aes.Mode = CipherMode.CBC;
aes.IV = iv;
aes.Key = passwordHash;
aes.Padding = PaddingMode.PKCS7;
aes.KeySize = 256;