SymmetricAlgorithm.Key 屬性

定義

取得或設定對稱演算法的祕密金鑰。Gets or sets the secret key for the symmetric algorithm.

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

屬性值

Byte[]

對稱演算法所用的祕密金鑰。The secret key to use for the symmetric algorithm.

例外狀況

嘗試將金鑰設定為 nullAn attempt was made to set the key to null.

金鑰大小無效。The key size is invalid.

備註

秘密金鑰用於加密和解密。The secret key is used both for encryption and for decryption. 若要讓對稱演算法成功,只有傳送者和接收者才必須知道秘密金鑰。For a symmetric algorithm to be successful, the secret key must be known only to the sender and the receiver. 有效的金鑰大小是由特定的對稱演算法執行所指定,並且會列在 LegalKeySizes 屬性中。The valid key sizes are specified by the particular symmetric algorithm implementation and are listed in the LegalKeySizes property.

如果此屬性在使用時 null,則會呼叫 GenerateKey 方法來建立新的隨機值。If this property is null when it is used, the GenerateKey method is called to create a new random value.

適用於

另請參閱