HMAC.Create 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
建立一個基於雜湊的訊息認證碼實HMAC作實例()。
多載
| 名稱 | Description |
|---|---|
| Create() |
已淘汰.
已淘汰.
建立基於雜湊的訊息認證碼(HMAC)預設實作實例。 |
| Create(String) |
已淘汰.
建立指定實作的基於雜湊的訊息認證碼(HMAC)實例。 |
Create()
- 來源:
- HMAC.cs
- 來源:
- HMAC.cs
- 來源:
- 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
傳回
一個新的 SHA-1 實例,除非預設設定已透過使用 <cryptoClass> 元素更改。
- 屬性
例外狀況
.NET Core 2.0 - 3.1 及 .NET 5 及以後版本:適用於所有版本。
備註
此方法在 .NET 5 及更新版本中已過時。
預設情況下,此超載使用 HMAC 的 SHA-1 實作。 如果你想指定不同的實作,可以用 Create(String) overload,這樣可以指定演算法名稱。
由於 SHA-1 發生衝突問題,Microsoft 建議採用基於 SHA-256 或更高層級的安全性模型。
適用於
Create(String)
- 來源:
- HMAC.cs
- 來源:
- HMAC.cs
- 來源:
- 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);
[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.HMAC? Create(string algorithmName);
public static System.Security.Cryptography.HMAC? Create(string algorithmName);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The default algorithm implementations might be removed, use strong type references like 'RSA.Create()' instead.")]
public static System.Security.Cryptography.HMAC? Create(string algorithmName);
public static System.Security.Cryptography.HMAC Create(string algorithmName);
[<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.HMAC
static member Create : string -> System.Security.Cryptography.HMAC
[<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.HMAC
Public Shared Function Create (algorithmName As String) As HMAC
參數
- algorithmName
- String
使用 HMAC 實作。 下表顯示參數 algorithmName 的有效值及其映射演算法。
| 參數值 | 工具 |
|---|---|
| System.Security.Cryptography.HMAC | HMACSHA1 |
| System.Security.Cryptography.KeyedHashAlgorithm | HMACSHA1 |
| HMACMD5 | HMACMD5 |
| 系統.安全.密碼學.HMACMD5 | HMACMD5 |
| HMACRIPEMD160 | HMACRIPEMD160 |
| 系統.安全.密碼學.HMACRIPEMD160 | HMACRIPEMD160 |
| HMACSHA1 | HMACSHA1 |
| 系統.安全.密碼學.HMACSHA1 | HMACSHA1 |
| HMACSHA256 | HMACSHA256 |
| 系統.安全.密碼學.HMACSHA256 | HMACSHA256 |
| HMACSHA384 | HMACSHA384 |
| 系統.安全.密碼學.HMACSHA384 | HMACSHA384 |
| HMACSHA512 | HMACSHA512 |
| 系統。安全。密碼學。HMACSHA512 | HMACSHA512 |
| MACTripleDES | MACTripleDES |
| System.Security.Cryptography.MACTripleDES | MACTripleDES |
傳回
指定 HMAC 實作的新實例。
- 屬性
備註
HMAC 支援多種雜湊演算法,包括 MD5、SHA-1、SHA-256 和 RIPEMD160。 完整列表請參閱參數的支援值 algorithmName 。
由於 MD5 與 SHA-1 有衝突問題,Microsoft 建議採用以 SHA-256 或更完善的安全模型。