Hashing

Purpose

BLAKE2barrow-up-right is a cryptographic hash function. It takes a message of any size and produces a 128-bit to 512-bit hash.

This hash acts as a fingerprint for the data. Hashes can be used to uniquely identify messages, detect corruption, detect duplicate data, and index data in a hash table.

However, unkeyed hashes do not provide authentication (e.g. for Encrypt-then-MACarrow-up-right). Furthermore, they should be avoided for key derivation. Use the linked APIs instead.

triangle-exclamation
triangle-exclamation

Usage

ComputeHash

Fills a span with a hash computed from a message.

BLAKE2b.ComputeHash(Span<byte> hash, ReadOnlySpan<byte> message)

Exceptions

ArgumentOutOfRangeExceptionarrow-up-right

hash has a length less than MinHashSize or greater than MaxHashSize.

CryptographicExceptionarrow-up-right

The hash could not be computed.

ComputeHash

Fills a span with a hash computed from a Stream message. This is useful for hashing files.

Exceptions

ArgumentOutOfRangeExceptionarrow-up-right

hash has a length less than MinHashSize or greater than MaxHashSize.

ArgumentNullExceptionarrow-up-right

message is null.

InvalidOperationExceptionarrow-up-right

message cannot be read.

CryptographicExceptionarrow-up-right

The hash could not be computed.

IncrementalBLAKE2b

Provides support for computing a hash from several messages.

circle-exclamation

Exceptions

ArgumentOutOfRangeExceptionarrow-up-right

hashSize is less than MinHashSize or greater than MaxHashSize.

ArgumentOutOfRangeExceptionarrow-up-right

hash has a length not equal to hashSize.

CryptographicExceptionarrow-up-right

The hash could not be computed.

InvalidOperationExceptionarrow-up-right

Cannot update after finalizing or finalize twice (without reinitializing or restoring a cached state).

InvalidOperationExceptionarrow-up-right

Cannot cache the state after finalizing (without reinitializing).

InvalidOperationExceptionarrow-up-right

Cannot restore the state when it has not been cached.

ObjectDisposedExceptionarrow-up-right

The object has been disposed.

Constants

These are used for validation and/or save you defining your own constants.

Notes

triangle-exclamation
circle-exclamation
circle-check
circle-check
circle-info

The security level of BLAKE2b is 1/2 the output length (e.g. 128-bit security for a 256-bit hash).​

Last updated