HashAlgorithm.Create Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Creates an instance of an implementation of a hash algorithm.
Overloads
| Name | Description |
|---|---|
| Create() |
Creates an instance of the default implementation of a hash algorithm. |
| Create(String) |
Creates an instance of the specified implementation of a hash algorithm. |
Create()
Creates an instance of the default implementation of a hash algorithm.
public:
static System::Security::Cryptography::HashAlgorithm ^ Create();
public static System.Security.Cryptography.HashAlgorithm Create();
static member Create : unit -> System.Security.Cryptography.HashAlgorithm
Public Shared Function Create () As HashAlgorithm
Returns
A new SHA1CryptoServiceProvider instance, unless the default settings have been changed using the .
Exceptions
.NET Core 2.0 - 3.1 and .NET 5 and later: In all cases.
Remarks
This method is obsolete in .NET 5 and later versions.
By default, this overload uses the SHA1CryptoServiceProvider implementation of a hash algorithm. If you want to specify a different implementation, use the Create(String) overload, which lets you specify an algorithm name, instead. The cryptography configuration system defines the default implementation of HashAlgorithm.
Due to collision problems with SHA-1, Microsoft recommends a security model based on SHA-256 or better.
Applies to
Create(String)
Creates an instance of the specified implementation of a hash algorithm.
public:
static System::Security::Cryptography::HashAlgorithm ^ Create(System::String ^ hashName);
public static System.Security.Cryptography.HashAlgorithm Create(string hashName);
static member Create : string -> System.Security.Cryptography.HashAlgorithm
Public Shared Function Create (hashName As String) As HashAlgorithm
Parameters
- hashName
- String
The hash algorithm implementation to use. The following table shows the valid values for the hashName parameter and the algorithms they map to.
| Parameter value | Implements |
|---|---|
| SHA | SHA1CryptoServiceProvider |
| SHA1 | SHA1CryptoServiceProvider |
| System.Security.Cryptography.SHA1 | SHA1CryptoServiceProvider |
| System.Security.Cryptography.HashAlgorithm | SHA1CryptoServiceProvider |
| MD5 | MD5CryptoServiceProvider |
| System.Security.Cryptography.MD5 | MD5CryptoServiceProvider |
| SHA256 | SHA256Managed |
| SHA-256 | SHA256Managed |
| System.Security.Cryptography.SHA256 | SHA256Managed |
| SHA384 | SHA384Managed |
| SHA-384 | SHA384Managed |
| System.Security.Cryptography.SHA384 | SHA384Managed |
| SHA512 | SHA512Managed |
| SHA-512 | SHA512Managed |
| System.Security.Cryptography.SHA512 | SHA512Managed |
Returns
A new instance of the specified hash algorithm, or null if hashName is not a valid hash algorithm.