MD5 Class
Collapse the table of content
Expand the table of content

MD5 Class

Represents the abstract class from which all implementations of the MD5 hash algorithm inherit.

For a list of all members of this type, see MD5 Members.


[Visual Basic]
MustInherit Public Class MD5
   Inherits HashAlgorithm
public abstract class MD5 : HashAlgorithm
public __gc __abstract class MD5 : public HashAlgorithm
public abstract class MD5 extends HashAlgorithm

Thread Safety

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


Hash functions map binary strings of an arbitrary length to small binary strings of a fixed length. A cryptographic hash function has the property that it is computationally infeasible to find two distinct inputs that hash to the same value; that is, 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.


[Visual Basic, C#, C++] The following example computes the MD5 hash for data and stores it in result. This example assumes that there is a predefined constant DATA_SIZE.

[Visual Basic] 
Dim data(DATA_SIZE) As Byte

' This is one implementation of the abstract class MD5.
Dim md5 As New MD5CryptoServiceProvider()

Dim result As Byte() = md5.ComputeHash(data)

byte[] data = new byte[DATA_SIZE];

// This is one implementation of the abstract class MD5.
MD5 md5 = new MD5CryptoServiceProvider();

byte[] result = md5.ComputeHash(data);

Byte data[] = new Byte[DATA_SIZE];

// This is one implementation of the abstract class MD5.
MD5* md5 = new MD5CryptoServiceProvider();

Byte result[] = md5->ComputeHash(data);

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.


Namespace: System.Security.Cryptography

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

Assembly: Mscorlib (in Mscorlib.dll)

See Also

MD5 Members | System.Security.Cryptography Namespace | Cryptographic Services

© 2015 Microsoft