共用方式為


HashAlgorithm.Create 方法

定義

建立雜湊演算法的實作執行個體。

多載

Create()
已淘汰.
已淘汰.

建立雜湊演算法的預設實作執行個體。

Create(String)
已淘汰.

建立雜湊演算法之指定實作的執行個體。

Create()

來源:
HashAlgorithm.cs
來源:
HashAlgorithm.cs
來源:
HashAlgorithm.cs

警告

The default implementation of this cryptography algorithm is not supported

警告

The default implementation of this cryptography algorithm is not supported.

建立雜湊演算法的預設實作執行個體。

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

傳回

除非已經使用 變更預設設定,否則為新的 SHA1CryptoServiceProvider 執行個體。

屬性

例外狀況

.NET Core 2.0 - 3.1 和 .NET 5 和更新版本:在所有情況下。

備註

此方法在 .NET 5 和更新版本中已過時。

根據預設,此多載會使用 SHA1CryptoServiceProvider 哈希演算法的實作。 如果您想要指定不同的實作,請使用 Create(String) 多載,讓您改為指定演算法名稱。 密碼編譯組態系統會定義的預設實作 HashAlgorithm

由於 SHA1 的衝突問題,Microsoft 建議您使用以 SHA256 或更好的加密方式為基礎的安全性模型。

適用於

Create(String)

來源:
HashAlgorithm.cs
來源:
HashAlgorithm.cs
來源:
HashAlgorithm.cs

警告

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

建立雜湊演算法之指定實作的執行個體。

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

參數

hashName
String

要使用的雜湊演算法實作。 下表顯示 hashName 參數的有效值及其對應的演算法。

參數值 實作
SHASHA1CryptoServiceProvider
SHA1SHA1CryptoServiceProvider
System.Security.Cryptography.SHA1SHA1CryptoServiceProvider
System.Security.Cryptography.HashAlgorithmSHA1CryptoServiceProvider
MD5MD5CryptoServiceProvider
System.Security.Cryptography.MD5MD5CryptoServiceProvider
SHA256SHA256Managed
SHA-256SHA256Managed
System.Security.Cryptography.SHA256SHA256Managed
SHA384SHA384Managed
SHA-384SHA384Managed
System.Security.Cryptography.SHA384SHA384Managed
SHA512SHA512Managed
SHA-512SHA512Managed
System.Security.Cryptography.SHA512SHA512Managed

傳回

指定之雜湊演算法的新執行個體,如果 hashName 不是有效的雜湊演算法則為 null

屬性

適用於