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. 在这种情况下,如果密钥不可导出,则 CryptographicException 会引发。In 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.

适用于