HashAlgorithm.Create 方法  
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
创建哈希算法实现的实例。
重载
| Create() | 
		已过时.
	 
		已过时.
	 创建哈希算法的默认实现的实例。 | 
| Create(String) | 
		已过时.
	 创建哈希算法的指定实现的实例。 | 
Create()
- Source:
- HashAlgorithm.cs
- Source:
- HashAlgorithm.cs
- Source:
- HashAlgorithm.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::HashAlgorithm ^ 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.HashAlgorithm 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.HashAlgorithm Create();public static System.Security.Cryptography.HashAlgorithm 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.HashAlgorithm[<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.HashAlgorithmstatic member Create : unit -> System.Security.Cryptography.HashAlgorithmPublic Shared Function Create () As HashAlgorithm返回
一个新的 SHA1CryptoServiceProvider 实例,除非已使用更改默认设置。
- 属性
例外
.NET Core 2.0 - 3.1 和 .NET 5 及更高版本:在所有情况下。
注解
此方法在 .NET 5 及更高版本中已过时。
默认情况下,此重载使用 SHA1CryptoServiceProvider 哈希算法的 实现。 如果要指定其他实现,请使用 Create(String) 重载,以便指定算法名称。 加密配置系统定义 的默认实现 HashAlgorithm。
由于 SHA1 出现冲突问题,Microsoft 建议使用基于 SHA256 或更好的安全模型。
适用于
Create(String)
- Source:
- HashAlgorithm.cs
- Source:
- HashAlgorithm.cs
- Source:
- HashAlgorithm.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::HashAlgorithm ^ Create(System::String ^ hashName);public static System.Security.Cryptography.HashAlgorithm? Create(string hashName);[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.HashAlgorithm? Create(string hashName);public static System.Security.Cryptography.HashAlgorithm Create(string hashName);static member Create : string -> System.Security.Cryptography.HashAlgorithm[<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.HashAlgorithmPublic Shared Function Create (hashName As String) As HashAlgorithm参数
- hashName
- String
要使用的哈希算法的实现。 下表显示 hashName 参数的有效值以及它们映射到的算法。
| 参数值 | 实现为其类型参数 | 
|---|---|
| SHA | SHA1CryptoServiceProvider | 
| SHA1 | SHA1CryptoServiceProvider | 
| System.Security.Cryptography.SHA1 | SHA1CryptoServiceProvider | 
| System.Security.Cryptography.HashAlgorithm | SHA1CryptoServiceProvider | 
| MD5 | MD5CryptoServiceProvider | 
| System.Security.Cryptography.MD5 | MD5CryptoServiceProvider | 
| SHA256 | SHA256Managed | 
| SHA-256 | SHA256Managed | 
| System.Security.Cryptography.SHA256 | SHA256Managed | 
| SHA384 | SHA384Managed | 
| SHA-384 | SHA384Managed | 
| System.Security.Cryptography.SHA384 | SHA384Managed | 
| SHA512 | SHA512Managed | 
| SHA-512 | SHA512Managed | 
| System.Security.Cryptography.SHA512 | SHA512Managed | 
返回
所指定哈希算法,或 null 的新实例,如果 hashName 不是有效哈希算法。
- 属性