Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

HMAC.Key Property

Note: This property is new in the .NET Framework version 2.0.

Gets or sets the key to use in the hash algorithm.

Namespace: System.Security.Cryptography
Assembly: mscorlib (in mscorlib.dll)

public:
virtual property array<unsigned char>^ Key {
	array<unsigned char>^ get () override;
	void set (array<unsigned char>^ value) override;
}
/** @property */
public byte[] get_Key ()

/** @property */
public void set_Key (byte[] value)

public override function get Key () : byte[]

public override function set Key (value : byte[])

Property Value

The key to use in the hash algorithm.
Exception typeCondition

CryptographicException

An attempt is made to change the Key property after hashing has begun.

This property is the key for the keyed hash algorithm.

A Hash-based Message Authentication Code (HMAC) can be used to determine whether a message sent over an insecure channel has been tampered with, provided that the sender and receiver share a secret key. The sender computes the hash value for the original data and sends both the original data and the HMAC as a single message. The receiver recomputes the hash value on the received message and checks that the computed hash value matches the transmitted hash value.

HMAC can be used with any iterative cryptographic hash function, such as MD5 or SHA-1, in combination with a secret shared key. The cryptographic strength of HMAC depends on the properties of the underlying hash function.

Any change to the data or the hash value results in a mismatch, because knowledge of the secret key is required to change the message and reproduce the correct hash value. Therefore, if the original and computed hash values match, the message is authenticated.

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.