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.
Block sizes of 128, 160, 192, 224, and 256 bits are supported by the Rijndael algorithm, but only the 128-bit block size is specified in the AES standard. [Wikipedia]
You linked to the
RijndaelManaged class. The equivalent class for AES is
Regarding the difference between the classes:
AesManaged simply uses
RijndaelManaged with the block size set to 128.
RijndaelManaged are not FIPS compliant and when used will throw an exception if the FIPS Group Policy flag is set. At present in .NET there is no support for 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.