HMAC.Create 方法

定義

建立雜湊式訊息驗證碼 (HMAC) 實作的執行個體。

多載

Create()
已淘汰.
已淘汰.

建立雜湊式訊息驗證碼 (HMAC) 預設實作的執行個體。

Create(String)
已淘汰.

建立雜湊式訊息驗證碼 (HMAC) 之指定實作的執行個體。

Create()

來源:
HMAC.cs
來源:
HMAC.cs
來源:
HMAC.cs

警告

The default implementation of this cryptography algorithm is not supported

警告

The default implementation of this cryptography algorithm is not supported.

建立雜湊式訊息驗證碼 (HMAC) 預設實作的執行個體。

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

傳回

除非已使用 <cryptoClass> 項目變更預設設定,否則為新的 SHA-1 執行個體。

屬性

例外狀況

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

備註

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

根據預設,此多載會使用 HMAC 的 SHA-1 實作。 如果您想要指定不同的實作,請使用 Create(String) 多載,讓您改為指定演算法名稱。

由於 SHA-1 發生衝突問題,Microsoft建議以 SHA-256 或更新版本為基礎的安全性模型。

適用於

Create(String)

來源:
HMAC.cs
來源:
HMAC.cs
來源:
HMAC.cs

警告

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

建立雜湊式訊息驗證碼 (HMAC) 之指定實作的執行個體。

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

參數

algorithmName
String

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

參數值 實作
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

傳回

指定 HMAC 實作的新執行個體。

屬性

備註

HMAC 支援許杜哈希演算法,包括 MD5、SHA-1、SHA-256 和 RIPEMD160。 如需完整清單,請參閱 參數的支援值 algorithmName

由於 MD5 和 SHA-1 發生衝突問題,Microsoft建議以 SHA-256 或更高版本為基礎的安全性模型。

適用於