<PackageReference Include="System.IO.Hashing" Version="10.0.7" />

System.IO.Hashing.NonCryptographicHashAlgorithm

public abstract class NonCryptographicHashAlgorithm
Represents a non-cryptographic hash algorithm.
public int HashLengthInBytes { get; }

Gets the number of bytes produced from this hash algorithm.

protected NonCryptographicHashAlgorithm(int hashLengthInBytes)

Called from constructors in derived classes to initialize the NonCryptographicHashAlgorithm class.

public abstract void Append(ReadOnlySpan<byte> source)

When overridden in a derived class, appends the contents of source to the data already processed for the current hash computation.

public void Append(byte[] source)

Appends the contents of source to the data already processed for the current hash computation.

public void Append(Stream stream)

Appends the contents of stream to the data already processed for the current hash computation.

public Task AppendAsync(Stream stream, CancellationToken cancellationToken = default)

Asychronously reads the contents of stream and appends them to the data already processed for the current hash computation.

public byte[] GetCurrentHash()

Gets the current computed hash value without modifying accumulated state.

public int GetCurrentHash(Span<byte> destination)

Writes the computed hash value to destination without modifying accumulated state.

protected abstract void GetCurrentHashCore(Span<byte> destination)

When overridden in a derived class, writes the computed hash value to destination without modifying accumulated state.

public byte[] GetHashAndReset()

Gets the current computed hash value and clears the accumulated state.

public int GetHashAndReset(Span<byte> destination)

Writes the computed hash value to destination then clears the accumulated state.

protected virtual void GetHashAndResetCore(Span<byte> destination)

Writes the computed hash value to destination then clears the accumulated state.

public abstract void Reset()

When overridden in a derived class, resets the hash computation to the initial state.

public bool TryGetCurrentHash(Span<byte> destination, out int bytesWritten)

Attempts to write the computed hash value to destination without modifying accumulated state.

public bool TryGetHashAndReset(Span<byte> destination, out int bytesWritten)

Attempts to write the computed hash value to destination. If successful, clears the accumulated state.