Επεξεργασία

Κοινή χρήση μέσω


TripleDESCng.CreateEncryptor Method

Definition

Creates a 3DES symmetric encryptor object.

Overloads

CreateEncryptor()

Creates a symmetric 3DES encryptor object using the current key and initialization vector (IV).

CreateEncryptor(Byte[], Byte[])

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

CreateEncryptor()

Creates a symmetric 3DES encryptor object using the current key and initialization vector (IV).

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

Returns

A symmetric 3DES encryptor object.

Exceptions

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

Remarks

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

Applies to

CreateEncryptor(Byte[], Byte[])

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

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

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

Parameters

rgbKey
Byte[]

The secret key to use for the 3DES algorithm. The key size must be 192 bits.

rgbIV
Byte[]

The initialization vector to use for the 3DES algorithm.

Returns

A symmetric 3DES encryptor 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

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

Note

If you've created the TripleDESCng 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.

Applies to