Share via


KeyedHashAlgorithm.Create 方法

定義

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

多載

Create()
已淘汰.
已淘汰.

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

Create(String)
已淘汰.

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

Create()

來源:
KeyedHashAlgorithm.cs
來源:
KeyedHashAlgorithm.cs
來源:
KeyedHashAlgorithm.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::KeyedHashAlgorithm ^ 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.KeyedHashAlgorithm 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.KeyedHashAlgorithm Create ();
public static System.Security.Cryptography.KeyedHashAlgorithm 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.KeyedHashAlgorithm
[<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.KeyedHashAlgorithm
static member Create : unit -> System.Security.Cryptography.KeyedHashAlgorithm
Public Shared Function Create () As KeyedHashAlgorithm

傳回

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

屬性

備註

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

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

另請參閱

適用於

Create(String)

來源:
KeyedHashAlgorithm.cs
來源:
KeyedHashAlgorithm.cs
來源:
KeyedHashAlgorithm.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::KeyedHashAlgorithm ^ Create(System::String ^ algName);
public static System.Security.Cryptography.KeyedHashAlgorithm? Create (string algName);
[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.KeyedHashAlgorithm? Create (string algName);
public static System.Security.Cryptography.KeyedHashAlgorithm Create (string algName);
static member Create : string -> System.Security.Cryptography.KeyedHashAlgorithm
[<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.KeyedHashAlgorithm
Public Shared Function Create (algName As String) As KeyedHashAlgorithm

參數

algName
String

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

參數值 實作
System.Security.Cryptography.HMACHMACSHA1
System.Security.Cryptography.KeyedHashAlgorithmHMACSHA1
HMACMD5HMACMD5
System.Security.Cryptography.HMACMD5HMACMD5
HMACRIPEMD160HMACRIPEMD160
System.Security.Cryptography.HMACRIPEMD160HMACRIPEMD160
HMACSHA1HMACSHA1
System.Security.Cryptography.HMACSHA1HMACSHA1
HMACSHA256HMACSHA256
System.Security.Cryptography.HMACSHA256HMACSHA256
HMACSHA384HMACSHA384
System.Security.Cryptography.HMACSHA384HMACSHA384
HMACSHA512HMACSHA512
System.Security.Cryptography.HMACSHA512HMACSHA512
MACTripleDESMACTripleDES
System.Security.Cryptography.MACTripleDESMACTripleDES

傳回

所指定金鑰雜湊演算法的新執行個體。

屬性

例外狀況

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

備註

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

這個方法支援許多演算法,包括 MD5、SHA-SHA-256 和RIPEMD160。 如需完整清單,請參閱 參數的支援值 algName

另請參閱

適用於