Redigera

Dela via


HashAlgorithm.Create Method

Definition

Creates an instance of an implementation of a hash algorithm.

Overloads

Create()
Obsolete.
Obsolete.

Creates an instance of the default implementation of a hash algorithm.

Create(String)
Obsolete.

Creates an instance of the specified implementation of a hash algorithm.

Create()

Source:
HashAlgorithm.cs
Source:
HashAlgorithm.cs
Source:
HashAlgorithm.cs

Caution

The default implementation of this cryptography algorithm is not supported

Caution

The default implementation of this cryptography algorithm is not supported.

Creates an instance of the default implementation of a hash algorithm.

public:
 static System::Security::Cryptography::HashAlgorithm ^ Create();
[System.Obsolete("The default implementation of this cryptography algorithm is not supported", DiagnosticId="SYSLIB0007", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public static System.Security.Cryptography.HashAlgorithm Create ();
[System.Obsolete("The default implementation of this cryptography algorithm is not supported.", DiagnosticId="SYSLIB0007", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public static System.Security.Cryptography.HashAlgorithm Create ();
public static System.Security.Cryptography.HashAlgorithm Create ();
[<System.Obsolete("The default implementation of this cryptography algorithm is not supported", DiagnosticId="SYSLIB0007", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
static member Create : unit -> System.Security.Cryptography.HashAlgorithm
[<System.Obsolete("The default implementation of this cryptography algorithm is not supported.", DiagnosticId="SYSLIB0007", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
static member Create : unit -> System.Security.Cryptography.HashAlgorithm
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 .

Attributes

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 SHA1, Microsoft recommends a security model based on SHA256 or better.

Applies to

Create(String)

Source:
HashAlgorithm.cs
Source:
HashAlgorithm.cs
Source:
HashAlgorithm.cs

Caution

Cryptographic factory methods accepting an algorithm name are obsolete. Use the parameterless Create factory method on the algorithm type instead.

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);
[System.Obsolete("Cryptographic factory methods accepting an algorithm name are obsolete. Use the parameterless Create factory method on the algorithm type instead.", DiagnosticId="SYSLIB0045", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public static System.Security.Cryptography.HashAlgorithm? Create (string hashName);
public static System.Security.Cryptography.HashAlgorithm Create (string hashName);
static member Create : string -> System.Security.Cryptography.HashAlgorithm
[<System.Obsolete("Cryptographic factory methods accepting an algorithm name are obsolete. Use the parameterless Create factory method on the algorithm type instead.", DiagnosticId="SYSLIB0045", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
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.

Attributes

Applies to