HashAlgorithm.Create Metoda

Definicja

Tworzy wystąpienie implementacji algorytmu skrótu.

Przeciążenia

Create()
Nieaktualne.
Nieaktualne.

Tworzy wystąpienie domyślnej implementacji algorytmu skrótu.

Create(String)

Tworzy wystąpienie określonej implementacji algorytmu skrótu.

Create()

Przestroga

The default implementation of this cryptography algorithm is not supported

Przestroga

The default implementation of this cryptography algorithm is not supported.

Tworzy wystąpienie domyślnej implementacji algorytmu skrótu.

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

Zwraca

HashAlgorithm

Nowe SHA1CryptoServiceProvider wystąpienie, chyba że ustawienia domyślne zostały zmienione przy użyciu polecenia .

Atrybuty

Wyjątki

.NET Core 2.0 — 3.1 i .NET 5 i nowsze: we wszystkich przypadkach.

Uwagi

Ta metoda jest przestarzała na platformie .NET 5 i nowszych wersjach.

Domyślnie to przeciążenie używa SHA1CryptoServiceProvider implementacji algorytmu skrótu. Jeśli chcesz określić inną implementację, użyj Create(String) przeciążenia, które umożliwia określenie nazwy algorytmu. System konfiguracji kryptografii definiuje domyślną implementację programu HashAlgorithm.

Ze względu na problemy z kolizją z algorytmem SHA1 firma Microsoft zaleca model zabezpieczeń oparty na algorytmie SHA256 lub lepszym.

Dotyczy

Create(String)

Tworzy wystąpienie określonej implementacji algorytmu skrótu.

public:
 static System::Security::Cryptography::HashAlgorithm ^ Create(System::String ^ hashName);
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
Public Shared Function Create (hashName As String) As HashAlgorithm

Parametry

hashName
String

Implementacja algorytmu skrótu do użycia. W poniższej tabeli przedstawiono prawidłowe wartości parametru hashName i algorytmy, do których są mapowe.

Wartość parametru Implementuje
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

Zwraca

HashAlgorithm

Nowe wystąpienie określonego algorytmu skrótu lub null jeśli hashName nie jest prawidłowym algorytmem skrótu.

Dotyczy