HashAlgorithm.Create 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
建立雜湊演算法的實作執行個體。
多載
Create() |
已淘汰.
已淘汰.
建立雜湊演算法的預設實作執行個體。 |
Create(String) |
已淘汰.
建立雜湊演算法之指定實作的執行個體。 |
Create()
警告
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)
警告
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
參數的有效值及其對應的演算法。
參數值 | 實作 |
---|---|
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 |
傳回
指定之雜湊演算法的新執行個體,如果 hashName
不是有效的雜湊演算法則為 null
。
- 屬性
適用於
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應