Export (0) Print
Expand All

SymmetricAlgorithm.Key Property

Gets or sets the secret key for the symmetric algorithm.

[Visual Basic]
Public Overridable Property Key As Byte ()
[C#]
public virtual byte[] Key {get; set;}
[C++]
public: __property virtual unsigned char get_Key();
public: __property virtual void set_Key(unsigned char __gc[]);
[JScript]
public function get Key() : Byte[];
public function set Key(Byte[]);

Property Value

The secret key to be used for the symmetric algorithm.

Exceptions

Exception Type Condition
ArgumentNullException An attempt is made to set the key to a null reference (Nothing in Visual Basic).

Remarks

The secret key is used both for encryption and for decryption. For a symmetric algorithm to be effective, the secret key must be known only to the sender and the receiver. The valid key sizes are specified by the particular symmetric algorithm implementation and are listed in LegalKeySizes.

If this property is a null reference (Nothing in Visual Basic) when it is used, GenerateKey is called to create a new random value.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

SymmetricAlgorithm Class | SymmetricAlgorithm Members | System.Security.Cryptography Namespace | Cryptographic Services

Show:
© 2014 Microsoft