Export (0) Print
Expand All

SHA1CryptoServiceProvider Class

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

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

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

[ComVisibleAttribute(true)]
public sealed class SHA1CryptoServiceProvider : SHA1

The SHA1CryptoServiceProvider type exposes the following members.

  NameDescription
Public methodSHA1CryptoServiceProviderInitializes a new instance of the SHA1CryptoServiceProvider class.
Top

  NameDescription
Public propertyCanReuseTransformGets a value indicating whether the current transform can be reused. (Inherited from HashAlgorithm.)
Public propertyCanTransformMultipleBlocksWhen overridden in a derived class, gets a value indicating whether multiple blocks can be transformed. (Inherited from HashAlgorithm.)
Public propertyHashGets the value of the computed hash code. (Inherited from HashAlgorithm.)
Public propertyHashSizeGets the size, in bits, of the computed hash code. (Inherited from HashAlgorithm.)
Public propertyInputBlockSizeWhen overridden in a derived class, gets the input block size. (Inherited from HashAlgorithm.)
Public propertyOutputBlockSizeWhen overridden in a derived class, gets the output block size. (Inherited from HashAlgorithm.)
Top

  NameDescription
Public methodClearReleases all resources used by the HashAlgorithm class. (Inherited from HashAlgorithm.)
Public methodComputeHash(Byte[])Computes the hash value for the specified byte array. (Inherited from HashAlgorithm.)
Public methodComputeHash(Stream)Computes the hash value for the specified Stream object. (Inherited from HashAlgorithm.)
Public methodComputeHash(Byte[], Int32, Int32)Computes the hash value for the specified region of the specified byte array. (Inherited from HashAlgorithm.)
Public methodDispose()Releases all resources used by the current instance of the HashAlgorithm class. (Inherited from HashAlgorithm.)
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodInitializeInitializes an instance of SHA1CryptoServiceProvider. (Overrides HashAlgorithm.Initialize().)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Public methodTransformBlockComputes the hash value for the specified region of the input byte array and copies the specified region of the input byte array to the specified region of the output byte array. (Inherited from HashAlgorithm.)
Public methodTransformFinalBlockComputes the hash value for the specified region of the specified byte array. (Inherited from HashAlgorithm.)
Top

  NameDescription
Protected fieldHashValueRepresents the value of the computed hash code. (Inherited from HashAlgorithm.)
Top

The hash size for the SHA1CryptoServiceProvider class is 160 bits.

Important noteImportant

This type implements the IDisposable interface. When you have finished using the type, you should dispose of it either directly or indirectly. To dispose of the type directly, call its Dispose method in a try/catch block. To dispose of it indirectly, use a language construct such as using (in C#) or Using (in Visual Basic). For more information, see the “Using an Object that Implements IDisposable” section in the IDisposable interface topic.

The following code example computes the SHA1 hash value for data and stores it in result. This example assumes that there is a predefined constant DATA_SIZE.

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);

.NET Framework

Supported in: 4.5.3, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

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