KeyedHashAlgorithm.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::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)
警告
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.HMAC | HMACSHA1 |
System.Security.Cryptography.KeyedHashAlgorithm | HMACSHA1 |
HMACMD5 | HMACMD5 |
System.Security.Cryptography.HMACMD5 | HMACMD5 |
HMACRIPEMD160 | HMACRIPEMD160 |
System.Security.Cryptography.HMACRIPEMD160 | HMACRIPEMD160 |
HMACSHA1 | HMACSHA1 |
System.Security.Cryptography.HMACSHA1 | HMACSHA1 |
HMACSHA256 | HMACSHA256 |
System.Security.Cryptography.HMACSHA256 | HMACSHA256 |
HMACSHA384 | HMACSHA384 |
System.Security.Cryptography.HMACSHA384 | HMACSHA384 |
HMACSHA512 | HMACSHA512 |
System.Security.Cryptography.HMACSHA512 | HMACSHA512 |
MACTripleDES | MACTripleDES |
System.Security.Cryptography.MACTripleDES | MACTripleDES |
傳回
所指定金鑰雜湊演算法的新執行個體。
- 屬性
例外狀況
.NET Core 2.0 - 3.1 和 .NET 5 和更新版本:在所有情況下。
備註
此方法在 .NET 5 和更新版本中已過時。
這個方法支援許多演算法,包括 MD5、SHA-SHA-256 和RIPEMD160。 如需完整清單,請參閱 參數的支援值 algName
。