HMAC.Create 方法
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
创建基于哈希的消息验证代码 (HMAC) 实现的实例。
Create() |
已过时.
已过时.
创建基于哈希的消息验证代码 (HMAC) 默认实现的实例。 |
Create(String) |
已过时.
创建基于哈希的消息验证代码 (HMAC) 指定实现的实例。 |
- Source:
- HMAC.cs
- Source:
- HMAC.cs
- Source:
- 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) 重载,它允许指定算法名称。
由于 SHA-1 的冲突问题,Microsoft 建议使用基于 SHA-256 或更高版本的安全模型。
适用于
.NET 9 和其他版本
产品 | 版本 (已过时) |
---|---|
.NET | Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1 (5, 6, 7, 8, 9) |
.NET Framework | 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0, 2.1 |
- Source:
- HMAC.cs
- Source:
- HMAC.cs
- Source:
- 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.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 |
返回
指定的 HMAC 实现的新实例。
- 属性
注解
HMAC 支持许多哈希算法,包括 MD5、SHA-1、SHA-256 和 RIPEMD160。 有关完整列表,请参阅 参数支持的值 algorithmName
。
由于 MD5 和 SHA-1 的冲突问题,Microsoft 建议使用基于 SHA-256 或更高版本的安全模型。
适用于
.NET 9 和其他版本
产品 | 版本 (已过时) |
---|---|
.NET | Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6 (7, 8, 9) |
.NET Framework | 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0, 2.1 |