AesCng.CreateEncryptor AesCng.CreateEncryptor AesCng.CreateEncryptor AesCng.CreateEncryptor Method

定义

创建 AES 对称加密器对象。Creates an AES symmetric encryptor object.

重载

CreateEncryptor() CreateEncryptor() CreateEncryptor() CreateEncryptor()

使用当前键和初始化向量 (IV) 创建对称 AES 加密器对象。Creates a symmetric AES encryptor object using the current key and initialization vector (IV).

CreateEncryptor(Byte[], Byte[]) CreateEncryptor(Byte[], Byte[]) CreateEncryptor(Byte[], Byte[]) CreateEncryptor(Byte[], Byte[])

用指定的密钥和初始化向量 (IV) 创建对称 AES 加密器对象。Creates a symmetric AES encryptor object with the specified key and initialization vector (IV).

CreateEncryptor() CreateEncryptor() CreateEncryptor() CreateEncryptor()

使用当前键和初始化向量 (IV) 创建对称 AES 加密器对象。Creates a symmetric AES 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

返回

对称 AES 加密器对象。A symmetric AES encryptor object.

注解

此方法用于加密消息,然后使用CreateDecryptor重载具有相同的签名进行解密此方法的结果。Use this method to encrypt a message and then use the CreateDecryptor overload with the same signature to decrypt the result of this method.

CreateEncryptor(Byte[], Byte[]) CreateEncryptor(Byte[], Byte[]) CreateEncryptor(Byte[], Byte[]) CreateEncryptor(Byte[], Byte[])

用指定的密钥和初始化向量 (IV) 创建对称 AES 加密器对象。Creates a symmetric AES 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);
override this.CreateEncryptor : byte[] * byte[] -> System.Security.Cryptography.ICryptoTransform
Public Overrides Function CreateEncryptor (rgbKey As Byte(), rgbIV As Byte()) As ICryptoTransform

参数

rgbKey
Byte[]

用于 AES 算法的密钥。The secret key to use for the AES algorithm. 密钥大小必须为 128、192 或 256 位。The key size must be 128, 192, or 256 bits.

rgbIV
Byte[]

用于 AES 算法的初始化向量。The initialization vector to use for the AES algorithm.

返回

对称 AES 加密器对象。A symmetric AES encryptor object.

异常

rgbKey 的大小对于此算法无效。rgbKey is not a valid size for this algorithm.

- 或 --or- rgbIV 的大小与此算法的块大小不匹配。rgbIV size does not match the block size for this algorithm.

rgbKey 是此算法的已知弱密钥,不能使用。rgbKey is a known weak key for this algorithm and cannot be used.

- 或 --or- rgbIVnullrgbIV is null.

注解

此方法用于加密消息,然后使用CreateDecryptor重载具有相同的签名进行解密此方法的结果。Use this method to encrypt a message and then use the CreateDecryptor overload with the same signature to decrypt the result of this method.

备注

如果你已创建AesCng对象使用的现有的保留的密钥和你想要使用的密钥对消息进行加密时,你想要设置IV属性,然后调用无参数CreateEncryptor()重载改为; 否则为使用此方法将创建由指定一个暂时的密钥rgbKey参数。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.

适用于