CryptographicOperations.TryHmacData Method

Definition

Attempts to compute the HMAC of data.

public:
 static bool TryHmacData(System::Security::Cryptography::HashAlgorithmName hashAlgorithm, ReadOnlySpan<System::Byte> key, ReadOnlySpan<System::Byte> source, Span<System::Byte> destination, [Runtime::InteropServices::Out] int % bytesWritten);
public static bool TryHmacData (System.Security.Cryptography.HashAlgorithmName hashAlgorithm, ReadOnlySpan<byte> key, ReadOnlySpan<byte> source, Span<byte> destination, out int bytesWritten);
static member TryHmacData : System.Security.Cryptography.HashAlgorithmName * ReadOnlySpan<byte> * ReadOnlySpan<byte> * Span<byte> * int -> bool
Public Shared Function TryHmacData (hashAlgorithm As HashAlgorithmName, key As ReadOnlySpan(Of Byte), source As ReadOnlySpan(Of Byte), destination As Span(Of Byte), ByRef bytesWritten As Integer) As Boolean

Parameters

hashAlgorithm
HashAlgorithmName

The algorithm used to compute the HMAC.

key
ReadOnlySpan<Byte>

The secret key. The key can be any length.

source
ReadOnlySpan<Byte>

The data to compute the HMAC over.

destination
Span<Byte>

The buffer to receive the HMAC value.

bytesWritten
Int32

When this method returns, the total number of bytes written into destination.

Returns

false if destination is too small to hold the calculated HMAC, true otherwise.

Exceptions

hashAlgorithm has a Name that is empty.

hashAlgorithm has a Name that is null.

hashAlgorithm specifies a hash algorithm not supported by the current platform.

hashAlgorithm specifies an unknown hash algorithm.

Applies to