TripleDESCng.CreateEncryptor 方法

定义

创建 3DES 对称加密器对象。

重载

CreateEncryptor()

使用当前键和初始化向量 (IV) 创建对称 3DES 加密器对象。

CreateEncryptor(Byte[], Byte[])

用指定的密钥和初始化向量 (IV) 创建对称 3DES 加密器对象。

CreateEncryptor()

使用当前键和初始化向量 (IV) 创建对称 3DES 加密器对象。

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

返回

ICryptoTransform

对称 3DES 加密器对象。

例外

.NET 6 及更高版本:选择 CFB64 模式并保留密钥。

注解

使用此方法加密消息,然后使用 CreateDecryptor 具有相同签名的重载来解密此方法的结果。

适用于

CreateEncryptor(Byte[], Byte[])

用指定的密钥和初始化向量 (IV) 创建对称 3DES 加密器对象。

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

参数

rgbKey
Byte[]

用于 3DES 算法的密钥。 密钥大小必须为 192 位。

rgbIV
Byte[]

用于 3DES 算法的初始化向量。

返回

ICryptoTransform

对称 3DES 加密器对象。

例外

rgbKeynull

rgbKey 的大小对于此算法无效。

  • 或 -

rgbIV 的大小与此算法的块大小不匹配。

rgbKey 是此算法的已知弱密钥,不能使用。

  • 或 -

rgbIVnull

注解

使用此方法加密消息,然后使用 CreateDecryptor 具有相同签名的重载来解密此方法的结果。

备注

如果已使用现有的持久化密钥创建了 TripleDESCng 对象,并且想要在加密消息时使用该密钥,则需要设置 IV 该属性,然后改为调用无 CreateEncryptor() 参数重载;否则,使用此方法将创建由参数指定的 rgbKey 临时密钥。

适用于