IncrementalHash.CreateHMAC 方法

定义

重载

CreateHMAC(HashAlgorithmName, Byte[])

使用指定的哈希算法和密钥为基于哈希的消息验证代码 (HMAC) 算法创建 IncrementalHash

CreateHMAC(HashAlgorithmName, ReadOnlySpan<Byte>)

使用 hashAlgorithm 指定的哈希算法和 key 指定的密钥为基于哈希的消息验证码 (HMAC) 算法创建 IncrementalHash

CreateHMAC(HashAlgorithmName, Byte[])

使用指定的哈希算法和密钥为基于哈希的消息验证代码 (HMAC) 算法创建 IncrementalHash

public:
 static System::Security::Cryptography::IncrementalHash ^ CreateHMAC(System::Security::Cryptography::HashAlgorithmName hashAlgorithm, cli::array <System::Byte> ^ key);
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public static System.Security.Cryptography.IncrementalHash CreateHMAC (System.Security.Cryptography.HashAlgorithmName hashAlgorithm, byte[] key);
public static System.Security.Cryptography.IncrementalHash CreateHMAC (System.Security.Cryptography.HashAlgorithmName hashAlgorithm, byte[] key);
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
static member CreateHMAC : System.Security.Cryptography.HashAlgorithmName * byte[] -> System.Security.Cryptography.IncrementalHash
static member CreateHMAC : System.Security.Cryptography.HashAlgorithmName * byte[] -> System.Security.Cryptography.IncrementalHash
Public Shared Function CreateHMAC (hashAlgorithm As HashAlgorithmName, key As Byte()) As IncrementalHash

参数

hashAlgorithm
HashAlgorithmName

要在 HMAC 内执行的哈希算法的名称。

key
Byte[]

HMAC 的密钥。 密钥可以为任何长度,但将对长度超过指定哈希算法的输出大小的密钥进行哈希处理,以便派生大小正确的密钥。 因此,建议的密钥大小为指定哈希算法的输出大小。

返回

IncrementalHash

IncrementalHash 类的一个实例,该实例已准备好计算指定的哈希算法。

属性

例外

keynull

hashAlgorithm.Namenull 或空字符串。

hashAlgorithm 不是已知的哈希算法。

适用于

CreateHMAC(HashAlgorithmName, ReadOnlySpan<Byte>)

使用 hashAlgorithm 指定的哈希算法和 key 指定的密钥为基于哈希的消息验证码 (HMAC) 算法创建 IncrementalHash

public:
 static System::Security::Cryptography::IncrementalHash ^ CreateHMAC(System::Security::Cryptography::HashAlgorithmName hashAlgorithm, ReadOnlySpan<System::Byte> key);
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public static System.Security.Cryptography.IncrementalHash CreateHMAC (System.Security.Cryptography.HashAlgorithmName hashAlgorithm, ReadOnlySpan<byte> key);
public static System.Security.Cryptography.IncrementalHash CreateHMAC (System.Security.Cryptography.HashAlgorithmName hashAlgorithm, ReadOnlySpan<byte> key);
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
static member CreateHMAC : System.Security.Cryptography.HashAlgorithmName * ReadOnlySpan<byte> -> System.Security.Cryptography.IncrementalHash
static member CreateHMAC : System.Security.Cryptography.HashAlgorithmName * ReadOnlySpan<byte> -> System.Security.Cryptography.IncrementalHash
Public Shared Function CreateHMAC (hashAlgorithm As HashAlgorithmName, key As ReadOnlySpan(Of Byte)) As IncrementalHash

参数

hashAlgorithm
HashAlgorithmName

要在 HMAC 内执行的哈希算法的名称。

key
ReadOnlySpan<Byte>

HMAC 的密钥。 密钥可以为任何长度,但将对长度超过 hashAlgorithm 指定的哈希算法的输出大小的密钥进行哈希处理(使用 hashAlgorithm 指定的算法),以便派生大小正确的密钥。 因此,建议的密钥大小为 hashAlgorithm 指定的哈希的输出大小。

返回

IncrementalHash

一个哈希实例,它用于计算 hashAlgorithm 指定的哈希算法。

属性

例外

hashAlgorithm.Namenull 或为空字符串。

hashAlgorithm 不是已知的哈希算法。

适用于