แก้ไข

แชร์ผ่าน


CryptographicOperations.HashDataAsync Method

Definition

Overloads

HashDataAsync(HashAlgorithmName, Stream, CancellationToken)

Asynchronously computes the hash of a stream.

HashDataAsync(HashAlgorithmName, Stream, Memory<Byte>, CancellationToken)

Asynchronously computes the hash of a stream.

HashDataAsync(HashAlgorithmName, Stream, CancellationToken)

Source:
CryptographicOperations.cs

Asynchronously computes the hash of a stream.

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

Parameters

hashAlgorithm
HashAlgorithmName

The algorithm used to compute the hash.

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.

-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

HashDataAsync(HashAlgorithmName, Stream, Memory<Byte>, CancellationToken)

Source:
CryptographicOperations.cs

Asynchronously computes the hash of a stream.

public static System.Threading.Tasks.ValueTask<int> HashDataAsync (System.Security.Cryptography.HashAlgorithmName hashAlgorithm, System.IO.Stream source, Memory<byte> destination, System.Threading.CancellationToken cancellationToken = default);
static member HashDataAsync : System.Security.Cryptography.HashAlgorithmName * System.IO.Stream * Memory<byte> * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<int>
Public Shared Function HashDataAsync (hashAlgorithm As HashAlgorithmName, 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 hash.

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.

-or-

hashAlgorithm has a Name that is null.

The buffer in destination is too small to hold the calculated hash 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