Edit

Share via


CryptographicOperations.HmacDataAsync Method

Definition

Overloads

HmacDataAsync(HashAlgorithmName, Byte[], Stream, CancellationToken)

Asynchronously computes the HMAC of a stream.

HmacDataAsync(HashAlgorithmName, ReadOnlyMemory<Byte>, Stream, CancellationToken)

Asynchronously computes the HMAC of a stream.

HmacDataAsync(HashAlgorithmName, ReadOnlyMemory<Byte>, Stream, Memory<Byte>, CancellationToken)

Asynchronously computes the HMAC of a stream.

HmacDataAsync(HashAlgorithmName, Byte[], Stream, CancellationToken)

Source:
CryptographicOperations.cs

Asynchronously computes the HMAC of a stream.

public static System.Threading.Tasks.ValueTask<byte[]> HmacDataAsync (System.Security.Cryptography.HashAlgorithmName hashAlgorithm, byte[] key, System.IO.Stream source, System.Threading.CancellationToken cancellationToken = default);
static member HmacDataAsync : System.Security.Cryptography.HashAlgorithmName * byte[] * System.IO.Stream * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<byte[]>
Public Shared Function HmacDataAsync (hashAlgorithm As HashAlgorithmName, key As Byte(), source As Stream, Optional cancellationToken As CancellationToken = Nothing) As ValueTask(Of Byte())

Parameters

hashAlgorithm
HashAlgorithmName

The algorithm used to compute the HMAC.

key
Byte[]

The secret key. The key can be any length.

source
Stream

The stream to compute the HMAC over.

cancellationToken
CancellationToken

The token to monitor for cancellation requests. The default value is None.

Returns

The HMAC of the data.

Exceptions

key or source is null.

-or-

hashAlgorithm has a Name that is null.

hashAlgorithm has a Name that is empty.

-or-

source does not support reading.

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

hashAlgorithm specifies an unknown hash algorithm.

cancellationToken has been canceled.

Applies to

HmacDataAsync(HashAlgorithmName, ReadOnlyMemory<Byte>, Stream, CancellationToken)

Source:
CryptographicOperations.cs

Asynchronously computes the HMAC of a stream.

public static System.Threading.Tasks.ValueTask<byte[]> HmacDataAsync (System.Security.Cryptography.HashAlgorithmName hashAlgorithm, ReadOnlyMemory<byte> key, System.IO.Stream source, System.Threading.CancellationToken cancellationToken = default);
static member HmacDataAsync : System.Security.Cryptography.HashAlgorithmName * ReadOnlyMemory<byte> * System.IO.Stream * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<byte[]>
Public Shared Function HmacDataAsync (hashAlgorithm As HashAlgorithmName, key As ReadOnlyMemory(Of Byte), source As Stream, Optional cancellationToken As CancellationToken = Nothing) As ValueTask(Of Byte())

Parameters

hashAlgorithm
HashAlgorithmName

The algorithm used to compute the HMAC.

key
ReadOnlyMemory<Byte>

The secret key. The key can be any length.

source
Stream

The stream to compute the HMAC over.

cancellationToken
CancellationToken

The token to monitor for cancellation requests. The default value is None.

Returns

The HMAC of the data.

Exceptions

source is null.

-or-

hashAlgorithm has a Name that is null.

hashAlgorithm has a Name that is empty.

-or-

source does not support reading.

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

hashAlgorithm specifies an unknown hash algorithm.

cancellationToken has been canceled.

Applies to

HmacDataAsync(HashAlgorithmName, ReadOnlyMemory<Byte>, Stream, Memory<Byte>, CancellationToken)

Source:
CryptographicOperations.cs

Asynchronously computes the HMAC of a stream.

public static System.Threading.Tasks.ValueTask<int> HmacDataAsync (System.Security.Cryptography.HashAlgorithmName hashAlgorithm, ReadOnlyMemory<byte> key, System.IO.Stream source, Memory<byte> destination, System.Threading.CancellationToken cancellationToken = default);
static member HmacDataAsync : System.Security.Cryptography.HashAlgorithmName * ReadOnlyMemory<byte> * System.IO.Stream * Memory<byte> * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<int>
Public Shared Function HmacDataAsync (hashAlgorithm As HashAlgorithmName, key As ReadOnlyMemory(Of Byte), source As Stream, destination As Memory(Of Byte), Optional cancellationToken As CancellationToken = Nothing) As ValueTask(Of Integer)

Parameters

hashAlgorithm
HashAlgorithmName

The algorithm used to compute the HMAC.

key
ReadOnlyMemory<Byte>

The secret key. The key can be any length.

source
Stream

The stream to compute the HMAC over.

destination
Memory<Byte>

The buffer to receive the HMAC value.

cancellationToken
CancellationToken

The token to monitor for cancellation requests. The default value is None.

Returns

The total number of bytes written to destination.

Exceptions

source is null.

-or-

hashAlgorithm has a Name that is null.

The buffer in destination is too small to hold the calculated HMAC size.

-or-

hashAlgorithm has a Name that is empty.

-or-

source does not support reading.

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

hashAlgorithm specifies an unknown hash algorithm.

cancellationToken has been canceled.

Applies to