Export (0) Print
Expand All

HashAlgorithm Class

Represents the base class from which all implementations of cryptographic hash algorithms must derive.

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

[ComVisibleAttribute(true)] 
public abstract class HashAlgorithm : ICryptoTransform, IDisposable
/** @attribute ComVisibleAttribute(true) */ 
public abstract class HashAlgorithm implements ICryptoTransform, IDisposable
ComVisibleAttribute(true) 
public abstract class HashAlgorithm implements ICryptoTransform, IDisposable

Hash functions are fundamental to modern cryptography. These functions map binary strings of an arbitrary length to small binary strings of a fixed length, known as hash values. A cryptographic hash function has the property that it is computationally infeasible to find two distinct inputs that hash to the same value. Hash functions are commonly used with digital signatures and for data integrity.

The hash is used as a unique value of fixed size representing a large amount of data. Hashes of two sets of data should match if the corresponding data also matches. Small changes to the data result in large unpredictable changes in the hash.

Notes to Inheritors When you inherit from the HashAlgorithm class, you must override the following members: HashCore and HashFinal.

The following code example computes the SHA1CryptoServiceProvider hash for an array. This example assumes that there is a predefined byte array dataArray[]. SHA1CryptoServiceProvider is a derived class of HashAlgorithm.

HashAlgorithm sha = new SHA1CryptoServiceProvider();
byte[] result = sha.ComputeHash(dataArray);

HashAlgorithm sha = new SHA1CryptoServiceProvider();
ubyte result[] = sha.ComputeHash(dataArray);

System.Object
  System.Security.Cryptography.HashAlgorithm
     Derived Classes

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, 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, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0

Community Additions

ADD
Show:
© 2014 Microsoft