This documentation is archived and is not being maintained.

SHA1Managed Class

Computes the SHA1 hash for the input data using the managed library.

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


[Visual Basic]
Public Class SHA1Managed
   Inherits SHA1
public class SHA1Managed : SHA1
public __gc class SHA1Managed : public SHA1
public class SHA1Managed extends SHA1

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.


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 and only if the corresponding data also matches. Small changes to the data result in large unpredictable changes in the hash.

This is a purely managed implementation of SHA1 that does not wrap CAPI.

The hash size for the SHA1Managed algorithm is 160 bits.


[Visual Basic, C#, C++] The following example computes the SHA1Managed 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
Dim result() As Byte
Dim shaM As New SHA1Managed()
result = shaM.ComputeHash(data)

byte[] data = new byte[DATA_SIZE];
byte[] result;
SHA1 shaM = new SHA1Managed();
result = shaM.ComputeHash(data);

Byte data[] = new Byte[DATA_SIZE];
Byte result[];
SHA1* shaM = new SHA1Managed();
result = shaM->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

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