SHA384.HashDataAsync Method

Definition

Overloads

HashDataAsync(Stream, CancellationToken)

Asynchronously computes the hash of a stream using the SHA384 algorithm.

HashDataAsync(Stream, Memory<Byte>, CancellationToken)

Asynchronously computes the hash of a stream using the SHA384 algorithm.

HashDataAsync(Stream, CancellationToken)

Source:
SHA384.cs
Source:
SHA384.cs
Source:
SHA384.cs

Asynchronously computes the hash of a stream using the SHA384 algorithm.

C#
public static System.Threading.Tasks.ValueTask<byte[]> HashDataAsync(System.IO.Stream source, System.Threading.CancellationToken cancellationToken = default);

Parameters

source
Stream

The stream to hash.

cancellationToken
CancellationToken

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

Returns

The hash of the data.

Exceptions

source is null.

source does not support reading.

The cancellation token was canceled. This exception is stored into the returned task.

Remarks

This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as ArgumentException, are still thrown synchronously. For the stored exceptions, see the exceptions thrown by HashData(Stream).

Applies to

.NET 10 and other versions
Product Versions
.NET 7, 8, 9, 10

HashDataAsync(Stream, Memory<Byte>, CancellationToken)

Source:
SHA384.cs
Source:
SHA384.cs
Source:
SHA384.cs

Asynchronously computes the hash of a stream using the SHA384 algorithm.

C#
public static System.Threading.Tasks.ValueTask<int> HashDataAsync(System.IO.Stream source, Memory<byte> destination, System.Threading.CancellationToken cancellationToken = default);

Parameters

source
Stream

The stream to hash.

destination
Memory<Byte>

The buffer to receive the hash 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.

The buffer in destination is too small to hold the calculated hash size. The SHA384 algorithm always produces a 384-bit hash, or 48 bytes.

-or-

source does not support reading.

The cancellation token was canceled. This exception is stored into the returned task.

Applies to

.NET 10 and other versions
Product Versions
.NET 7, 8, 9, 10