AesCng.Key 屬性

定義

取得或設定 AesCng 演算法的金鑰。Gets or sets the key for the AesCng algorithm.

public:
 virtual property cli::array <System::Byte> ^ Key { cli::array <System::Byte> ^ get(); void set(cli::array <System::Byte> ^ value); };
public override byte[] Key { get; set; }
member this.Key : byte[] with get, set
Public Overrides Property Key As Byte()

屬性值

Byte[]

AesCng 演算法的金鑰。The key for the AesCng algorithm.

備註

如果您已 AesCng 使用現有的保存金鑰建立物件,則當您讀取屬性的值時 Key ,將會嘗試匯出金鑰。If you've created the AesCng object using an existing persisted key, when you read the value of the Key property, an attempt to export the key will be made. 在此情況下,如果無法匯出金鑰,將會擲回 CryptographicExceptionIn this case, if the key is not exportable, a CryptographicException will be thrown.

此外,如果您設定屬性的值,將不會 Key 再使用保存的金鑰,而會改用暫存金鑰。In addition to that, if you set the value of the Key property, the persisted key will no longer be used and a temporary key will be used instead. 如果您需要再次使用保存的金鑰,則必須建立類別的新實例 AesCngIf you need to use the persisted key again, a new instance of AesCng class needs to be created.

適用於