I needed to encrypt data using AES. While researching I discovered the AesCryptoServiceProvider class.
I know very little about encryption and I did not know what the initialization vector (IV) was, so I tried searching for an AES example in stack overflow and that lead me to this question.
Why does the stack overflow link uses the RijndaelManaged class? Are the RijndaelManaged and AesCryptoServiceProvider classes doing the same thing?
AES is based on Rijndael but with the block size restricted to 128-bits. Rijndael supports a wider range of block sizes and many cryptographic libraries supply a separate Rijndael implementation to complement AES.
You linked to the
RijndaelManagedclass. The equivalent class for AES isAesManaged.Regarding the difference between the classes:
AesManagedsimply usesRijndaelManagedwith the block size set to 128.AesManagedandRijndaelManagedare not FIPS compliant and when used will throw an exception if the FIPS Group Policy flag is set. .NET Framework 4.6.2 (August 2016) added the AesCng class, an implementation of the CNG version of the AES algorithm.An IV is a piece of random data, equal in length to the block size, which is required by certain symmetric modes of operation (e.g. CBC-mode). Typically the IV is combined (XOR-ed) with the first block of plaintext or the first block of ciphertext. The idea is to ensure that encrypting the same message twice with the same key will not result in the same output.