AesCng.CreateEncryptor 方法

定義

建立 AES 對稱加密子物件。

多載

CreateEncryptor()

使用目前的索引鍵和初始化向量 (IV) 建立對稱 AES 加密子物件。

CreateEncryptor(Byte[], Byte[])

使用指定的金鑰和初始化向量 (IV) 建立對稱 AES 加密子物件。

CreateEncryptor()

使用目前的索引鍵和初始化向量 (IV) 建立對稱 AES 加密子物件。

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 加密子物件。

例外狀況

.NET 6 和更新版本:已選取 CFB128 模式,並保存金鑰。

備註

使用此方法來加密訊息,然後使用 CreateDecryptor 具有相同簽章的多載來解密此方法的結果。

適用於

CreateEncryptor(Byte[], Byte[])

來源:
Cng.NotSupported.cs
來源:
Cng.NotSupported.cs
來源:
Cng.NotSupported.cs

使用指定的金鑰和初始化向量 (IV) 建立對稱 AES 加密子物件。

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[]

AES 演算法所用的祕密金鑰。 金鑰大小必須是 128、192 或 256 位元。

rgbIV
Byte[]

AES 演算法所用的初始化向量。

傳回

對稱 AES 加密子物件。

例外狀況

rgbKeynull

rgbKey 的大小不適用於此演算法。

-或-

rgbIV 的大小不符合此演算法的區塊大小。

rgbKey 是此演算法的已知弱式金鑰,因此無法使用。

-或-

rgbIVnull

備註

使用此方法來加密訊息,然後使用 CreateDecryptor 具有相同簽章的多載來解密此方法的結果。

注意

如果您已使用現有的保存金鑰建立 AesCng 物件,而且想要在加密訊息時使用該金鑰,則您想要設定 IV 屬性,然後改為呼叫無 CreateEncryptor() 參數多載;否則,使用此方法會建立參數所 rgbKey 指定的暫時金鑰。

適用於