This documentation is archived and is not being maintained.

SHA1CryptoServiceProvider Class

Computes the SHA1 hash for the input data using the implementation provided by the cryptographic service provider (CSP). This class cannot be inherited.

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

System.Object
   System.Security.Cryptography.HashAlgorithm
      System.Security.Cryptography.SHA1
         System.Security.Cryptography.SHA1CryptoServiceProvider

[Visual Basic]
NotInheritable Public Class SHA1CryptoServiceProvider
   Inherits SHA1
[C#]
public sealed class SHA1CryptoServiceProvider : SHA1
[C++]
public __gc __sealed class SHA1CryptoServiceProvider : public SHA1
[JScript]
public class SHA1CryptoServiceProvider 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.

Example

[Visual Basic, C#, C++] The following example computes the SHA1 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 sha As New SHA1CryptoServiceProvider()
' This is one implementation of the abstract class SHA1.
result = sha.ComputeHash(data)

[C#] 
byte[] data = new byte[DATA_SIZE];

byte[] result; 
 
SHA1 sha = new SHA1CryptoServiceProvider(); 
// This is one implementation of the abstract class SHA1.

result = sha.ComputeHash(data);

[C++] 
Byte data[] = new Byte[DATA_SIZE];

Byte result[]; 
 
SHA1* sha = new SHA1CryptoServiceProvider(); 
// This is one implementation of the abstract class SHA1.

result = sha->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.

Requirements

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

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

Show: