AesCng::CreateDecryptor Method (array<Byte>^, array<Byte>^)
Creates a symmetric AES decryptor object with the specified key and initialization vector (IV).
Assembly: System.Core (in System.Core.dll)
public: virtual ICryptoTransform^ CreateDecryptor( array<unsigned char>^ rgbKey, array<unsigned char>^ rgbIV ) override
Parameters
- rgbKey
-
Type:
array<System::Byte>^
The secret key to use for the AES algorithm. The key size must be 128, 192, or 256 bits.
- rgbIV
-
Type:
array<System::Byte>^
The initialization vector to use for the AES algorithm.
| Exception | Condition |
|---|---|
| ArgumentNullException | rgbKey is null. |
| ArgumentException | rgbKey is not a valid size for this algorithm. -or- rgbIV size does not match the block size for this algorithm. |
| CryptographicException | rgbKey is a known weak key for this algorithm and cannot be used. -or- rgbIV is null. |
This method decrypts an encrypted message created using the CreateEncryptor(array<Byte>^, array<Byte>^) overload with the same signature.
Note |
|---|
If you've created the AesCng object using an existing persisted key and you want to make use of that key when decrypting the message, you want to set the IV property and then call the parameterless CreateDecryptor() overload instead; otherwise, using this method will create an ephemeral key as specified by the rgbKey parameter. |
Available since 4.6.2
