HashAlgorithm.Create 方法

定義

建立一個雜湊演算法實作的實例。

多載

名稱 Description
Create()
已淘汰.
已淘汰.

建立一個雜湊演算法預設實作的實例。

Create(String)
已淘汰.

建立指定雜湊演算法實作的實例。

Create()

來源:
HashAlgorithm.cs
來源:
HashAlgorithm.cs
來源:
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) overload,這樣可以指定演算法名稱。 密碼學配置系統定義了 的 HashAlgorithm預設實作。

由於 SHA-1 發生衝突問題,Microsoft 建議採用基於 SHA-256 或更高層級的安全性模型。

適用於

Create(String)

來源:
HashAlgorithm.cs
來源:
HashAlgorithm.cs
來源:
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);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The default algorithm implementations might be removed, use strong type references like 'RSA.Create()' instead.")]
[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);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The default algorithm implementations might be removed, use strong type references like 'RSA.Create()' instead.")]
public static System.Security.Cryptography.HashAlgorithm? Create(string hashName);
public static System.Security.Cryptography.HashAlgorithm Create(string hashName);
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The default algorithm implementations might be removed, use strong type references like 'RSA.Create()' instead.")>]
[<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
static member Create : string -> System.Security.Cryptography.HashAlgorithm
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The default algorithm implementations might be removed, use strong type references like 'RSA.Create()' instead.")>]
static member Create : string -> System.Security.Cryptography.HashAlgorithm
Public Shared Function Create (hashName As String) As HashAlgorithm

參數

hashName
String

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

參數值 工具
SHA SHA1CryptoServiceProvider
SHA1 SHA1CryptoServiceProvider
系統.安全.密碼學.SHA1 SHA1CryptoServiceProvider
System.Security.Cryptography.HashAlgorithm SHA1CryptoServiceProvider
MD5 MD5CryptoServiceProvider
System.Security.Cryptography.MD5 MD5CryptoServiceProvider
SHA256 SHA256Managed
SHA-256 SHA256Managed
系統.安全.密碼學.SHA256 SHA256Managed
SHA384 SHA384Managed
SHA-384 SHA384Managed
系統.安全.密碼學.SHA384 SHA384Managed
SHA512 SHA512Managed
SHA-512 SHA512Managed
系統.安全.密碼學.SHA512 SHA512Managed

傳回

該雜湊演算法的新實例,或 nullhashName 不是有效的雜湊演算法,則表示該演算法不成立。

屬性

適用於