KeyedHashAlgorithm.Create 方法

定义

创建加密哈希算法实现的实例。Creates an instance of an implementation of a keyed hash algorithm.

重载

Create()

创建加密哈希算法的默认实现的实例。Creates an instance of the default implementation of a keyed hash algorithm.

Create(String)

创建加密哈希算法的指定实现的实例。Creates an instance of the specified implementation of a keyed hash algorithm.

Create()

创建加密哈希算法的默认实现的实例。Creates an instance of the default implementation of a keyed hash algorithm.

public:
 static System::Security::Cryptography::KeyedHashAlgorithm ^ Create();
public static System.Security.Cryptography.KeyedHashAlgorithm Create ();
static member Create : unit -> System.Security.Cryptography.KeyedHashAlgorithm
Public Shared Function Create () As KeyedHashAlgorithm

返回

HMACSHA1 实例,除非已更改默认设置。A new HMACSHA1 instance, unless the default settings have been changed.

注解

默认情况下,此重载使用加密哈希算法的 HMACSHA1 实现。By default, this overload uses the HMACSHA1 implementation of a keyed hash algorithm. 如果要指定其他实现,请使用 Create(String) 重载,这样就可以改为指定算法名称。If you want to specify a different implementation, use the Create(String) overload, which lets you specify an algorithm name, instead. 加密配置系统定义 KeyedHashAlgorithm 类的默认实现。The cryptography configuration system defines the default implementation of the KeyedHashAlgorithm class.

由于 SHA1 出现冲突问题,Microsoft 建议使用基于 SHA256 或更好的安全模型。Due to collision problems with SHA1, Microsoft recommends a security model based on SHA256 or better.

另请参阅

Create(String)

创建加密哈希算法的指定实现的实例。Creates an instance of the specified implementation of a keyed hash algorithm.

public:
 static System::Security::Cryptography::KeyedHashAlgorithm ^ Create(System::String ^ algName);
public static System.Security.Cryptography.KeyedHashAlgorithm Create (string algName);
static member Create : string -> System.Security.Cryptography.KeyedHashAlgorithm
Public Shared Function Create (algName As String) As KeyedHashAlgorithm

参数

algName
String

要使用的加密哈希算法实现。The keyed hash algorithm implementation to use. 下表显示 algName 参数的有效值以及它们映射到的算法。The following table shows the valid values for the algName parameter and the algorithms they map to.

参数值Parameter value 实现Implements
System.Security.Cryptography.HMACSystem.Security.Cryptography.HMAC HMACSHA1
System.Security.Cryptography.KeyedHashAlgorithmSystem.Security.Cryptography.KeyedHashAlgorithm HMACSHA1
HMACMD5HMACMD5 HMACMD5
System.Security.Cryptography.HMACMD5System.Security.Cryptography.HMACMD5 HMACMD5
HMACRIPEMD160HMACRIPEMD160 HMACRIPEMD160
System.Security.Cryptography.HMACRIPEMD160System.Security.Cryptography.HMACRIPEMD160 HMACRIPEMD160
HMACSHA1HMACSHA1 HMACSHA1
System.Security.Cryptography.HMACSHA1System.Security.Cryptography.HMACSHA1 HMACSHA1
HMACSHA256HMACSHA256 HMACSHA256
System.Security.Cryptography.HMACSHA256System.Security.Cryptography.HMACSHA256 HMACSHA256
HMACSHA384HMACSHA384 HMACSHA384
System.Security.Cryptography.HMACSHA384System.Security.Cryptography.HMACSHA384 HMACSHA384
HMACSHA512HMACSHA512 HMACSHA512
System.Security.Cryptography.HMACSHA512System.Security.Cryptography.HMACSHA512 HMACSHA512
MACTripleDESMACTripleDES MACTripleDES
System.Security.Cryptography.MACTripleDESSystem.Security.Cryptography.MACTripleDES MACTripleDES

返回

指定的加密哈希算法的新实例。A new instance of the specified keyed hash algorithm.

注解

此方法支持多种算法,包括 MD5、SHA-1、SHA-256 和 RIPEMD160。This method supports a number of algorithms, including MD5, SHA-1, SHA-256, and RIPEMD160. 有关完整列表,请参阅 algName 参数支持的值。For a full list, see the supported values for the algName parameter.

另请参阅

适用于