Export (0) Print
Expand All

AesCryptoServiceProvider.CreateEncryptor Method (Byte[], Byte[])

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

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

abstract CreateEncryptor : 
        key:byte[] * 
        iv:byte[] -> ICryptoTransform  
override CreateEncryptor : 
        key:byte[] * 
        iv:byte[] -> ICryptoTransform

Parameters

key
Type: System.Byte[]

The secret key to use for the symmetric algorithm.

iv
Type: System.Byte[]

The initialization vector to use for the symmetric algorithm.

Return Value

Type: System.Security.Cryptography.ICryptoTransform
A symmetric AES encryptor object.

ExceptionCondition
ArgumentNullException

The key or iv parameter is a null reference (Nothing in Visual Basic).

ArgumentException

key is invalid.

See the code examples in the LegalKeySizes and LegalBlockSizes properties to determine the size of the key and iv parameters.

The following example shows how to use the AesCryptoServiceProvider.CreateEncryptor method to encrypt a message. This code example is part of a larger example provided for the AesCryptoServiceProvider class.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Show:
© 2015 Microsoft