Upraviť

Zdieľať cez


AesCng.CreateDecryptor Method

Definition

Creates a symmetric decryptor object.

Overloads

CreateDecryptor()

Creates a symmetric AES decryptor object with the current key and initialization vector (IV).

CreateDecryptor(Byte[], Byte[])

Creates a symmetric AES decryptor object with the specified key and initialization vector (IV).

CreateDecryptor()

Creates a symmetric AES decryptor object with the current key and initialization vector (IV).

public:
 override System::Security::Cryptography::ICryptoTransform ^ CreateDecryptor();
public override System.Security.Cryptography.ICryptoTransform CreateDecryptor ();
override this.CreateDecryptor : unit -> System.Security.Cryptography.ICryptoTransform
Public Overrides Function CreateDecryptor () As ICryptoTransform

Returns

A symmetric AES decryptor object.

Exceptions

.NET 6 and later: CFB128 mode is selected and the key is persisted.

Remarks

This method decrypts an encrypted message created using the CreateEncryptor() overload with the same signature.

Applies to

CreateDecryptor(Byte[], Byte[])

Source:
Cng.NotSupported.cs
Source:
Cng.NotSupported.cs
Source:
Cng.NotSupported.cs

Creates a symmetric AES decryptor object with the specified key and initialization vector (IV).

public:
 override System::Security::Cryptography::ICryptoTransform ^ CreateDecryptor(cli::array <System::Byte> ^ rgbKey, cli::array <System::Byte> ^ rgbIV);
public override System.Security.Cryptography.ICryptoTransform CreateDecryptor (byte[] rgbKey, byte[]? rgbIV);
public override System.Security.Cryptography.ICryptoTransform CreateDecryptor (byte[] rgbKey, byte[] rgbIV);
override this.CreateDecryptor : byte[] * byte[] -> System.Security.Cryptography.ICryptoTransform
Public Overrides Function CreateDecryptor (rgbKey As Byte(), rgbIV As Byte()) As ICryptoTransform

Parameters

rgbKey
Byte[]

The secret key to use for the AES algorithm. The key size must be 128, 192, or 256 bits.

rgbIV
Byte[]

The initialization vector to use for the AES algorithm.

Returns

A symmetric AES decryptor object.

Exceptions

rgbKey is null.

rgbKey is not a valid size for this algorithm.

-or-

rgbIV size does not match the block size for this algorithm.

rgbKey is a known weak key for this algorithm and cannot be used.

-or-

rgbIV is null.

Remarks

This method decrypts an encrypted message created using the CreateEncryptor(Byte[], 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.

Applies to