Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

AesCng::CreateEncryptor Method (array<Byte>^, array<Byte>^)

 

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

Namespace:   System.Security.Cryptography
Assembly:  System.Core (in System.Core.dll)

public:
virtual ICryptoTransform^ CreateEncryptor(
	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.

Return Value

Type: System.Security.Cryptography::ICryptoTransform^

A symmetric AES encryptor object.

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.

Use this method to encrypt a message and then use the CreateDecryptor overload with the same signature to decrypt the result of this method.

System_CAPS_noteNote

If you've created the AesCng object using an existing persisted key and you want to make use of that key when encrypting the message, you want to set the IV property and then call the parameterless CreateEncryptor() overload instead; otherwise, using this method will create an ephemeral key as specified by the rgbKey parameter.

.NET Framework
Available since 4.6.2
Return to top
Show:
© 2017 Microsoft