Bewerken

Share via


HMAC.Initialize Method

Definition

Initializes an instance of the default implementation of HMAC.

public:
 override void Initialize();
public override void Initialize ();
override this.Initialize : unit -> unit
Public Overrides Sub Initialize ()

Remarks

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 will result 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.

Due to collision problems with MD5 and SHA-1, Microsoft recommends a security model based on SHA-256 or better.

Applies to