0

This is the code:

string key = "d771815a7f74ebfaa2d44f8b7654fa19e7a02452c2ab351d222e49297910a814";
AesCryptoServiceProvider aes = new AesCryptoServiceProvider();
aes.Padding = PaddingMode.None;
aes.Mode = CipherMode.ECB;
aes.BlockSize = 128;
aes.KeySize = 256;
aes.Key = ASCIIEncoding.ASCII.GetBytes(key);

It throws:

System.Security.Cryptography.CryptographicException: 'The specified key is not a valid size for this algorithm.'

Did I do something wrong?

GSerg
  • 76,472
  • 17
  • 159
  • 346
BHNHAT
  • 1
  • 1
    `Did I do something wrong` - you provided a key that is not a valid size for this algorithm? You specified 256 bits size and provided a 512 bit key. – GSerg Apr 29 '20 at 12:22
  • @GSerg Thanks, I solved the problem – BHNHAT Apr 29 '20 at 12:36

0 Answers0