IncrementalHash.CreateHMAC Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
CreateHMAC(HashAlgorithmName, Byte[]) |
Create an IncrementalHash for the Hash-based Message Authentication Code (HMAC)
algorithm utilizing the hash algorithm specified by |
CreateHMAC(HashAlgorithmName, ReadOnlySpan<Byte>) |
Create an IncrementalHash for the Hash-based Message Authentication Code (HMAC) algorithm utilizing the hash algorithm specified by |
CreateHMAC(HashAlgorithmName, Byte[])
- Source:
- IncrementalHash.cs
- Source:
- IncrementalHash.cs
- Source:
- IncrementalHash.cs
Create an IncrementalHash for the Hash-based Message Authentication Code (HMAC)
algorithm utilizing the hash algorithm specified by hashAlgorithm
, and a
key specified by key
.
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
Parameters
- hashAlgorithm
- HashAlgorithmName
The name of the hash algorithm to perform within the HMAC.
- key
- Byte[]
The secret key for the HMAC. The key can be any length, but a key longer than the output size
of the hash algorithm specified by hashAlgorithm
will be hashed (using the
algorithm specified by hashAlgorithm
) to derive a correctly-sized key. Therefore,
the recommended size of the secret key is the output size of the hash specified by
hashAlgorithm
.
Returns
An IncrementalHash instance ready to compute the hash algorithm specified
by hashAlgorithm
.
- Attributes
Exceptions
key
is null
.
hashAlgorithm
.Name is null
, or
the empty string.
hashAlgorithm
is not a known hash algorithm.
Applies to
CreateHMAC(HashAlgorithmName, ReadOnlySpan<Byte>)
- Source:
- IncrementalHash.cs
- Source:
- IncrementalHash.cs
- Source:
- IncrementalHash.cs
Create an IncrementalHash for the Hash-based Message Authentication Code (HMAC) algorithm utilizing the hash algorithm specified by hashAlgorithm
, and a key specified by key
.
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
Parameters
- hashAlgorithm
- HashAlgorithmName
The name of the hash algorithm to perform within the HMAC.
- key
- ReadOnlySpan<Byte>
The secret key for the HMAC.
Returns
A hash instance to compute the hash algorithm specified by hashAlgorithm
.
- Attributes
Exceptions
hashAlgorithm
.Name is null
or the empty string.
hashAlgorithm
is not a known hash algorithm.