Blake2b Class
Computes the BLAKE2b hash function (RFC 7693), with a digest of 1 to 64 bytes.
public sealed class Blake2bRemarks
Use the static Blake2b.HashData methods to hash data in one call, or an instance to append the data in several calls. Keyed hashing (BLAKE2b used as a MAC) is not supported.
Instances are not thread-safe.
Constructors
| Name | Description |
|---|---|
| Blake2b(int) | Initializes a new instance of the Blake2b class. |
Blake2b(int)
Blake2b.csInitializes a new instance of the Blake2b class.
public Blake2b(int hashSize = 64)Parameters
hashSizeint- The size of the digest, in bytes: 1 to
Blake2b.MaxHashSize.
Exceptions
ArgumentOutOfRangeExceptionhashSizeis not in the range 1 toBlake2b.MaxHashSize.
Properties
| Name | Description |
|---|---|
| HashSize | Gets the size of the digest, in bytes. |
HashSize
Blake2b.csMethods
| Name | Description |
|---|---|
| AppendData(ReadOnlySpan<byte>) | Appends data to the message. |
| GetHashAndReset() | Computes the digest of the appended data, and restarts the computation of a new digest of the same size. |
| GetHashAndReset(Span<byte>) | Computes the digest of the appended data into a buffer, and restarts the computation of a new digest of the same size. |
| HashData(ReadOnlySpan<byte>, int) | Computes the BLAKE2b digest of data. |
| HashData(ReadOnlySpan<byte>, Span<byte>) | Computes the BLAKE2b digest of data into a buffer. |
AppendData(ReadOnlySpan<byte>)
Blake2b.csAppends data to the message.
public void AppendData(ReadOnlySpan<byte> data)Parameters
dataReadOnlySpan<byte>- The data to append.
GetHashAndReset overloads
GetHashAndReset()
Blake2b.csComputes the digest of the appended data, and restarts the computation of a new digest of the same size.
public byte[] GetHashAndReset()Returns
byte[] The digest, of Blake2b.HashSize bytes.
GetHashAndReset(Span<byte>)
Blake2b.csComputes the digest of the appended data into a buffer, and restarts the computation of a new digest of the same size.
Parameters
destinationSpan<byte>- The buffer that receives the digest: its length must be
Blake2b.HashSize.
Exceptions
ArgumentException- The length of
destinationis notBlake2b.HashSize.
HashData overloads
HashData(ReadOnlySpan<byte>, int)
Blake2b.csComputes the BLAKE2b digest of data.
public static byte[] HashData(ReadOnlySpan<byte> source, int hashSize = 64)Parameters
sourceReadOnlySpan<byte>- The data to hash.
hashSizeint- The size of the digest, in bytes: 1 to
Blake2b.MaxHashSize.
Returns
byte[] The digest, of hashSize bytes.
Exceptions
ArgumentOutOfRangeExceptionhashSizeis not in the range 1 toBlake2b.MaxHashSize.
HashData(ReadOnlySpan<byte>, Span<byte>)
Blake2b.csComputes the BLAKE2b digest of data into a buffer.
public static void HashData(ReadOnlySpan<byte> source, Span<byte> destination)Parameters
sourceReadOnlySpan<byte>- The data to hash.
destinationSpan<byte>- The buffer that receives the digest: its length, 1 to
Blake2b.MaxHashSizebytes, is the size of the digest.
Exceptions
ArgumentOutOfRangeException- The length of
destinationis not in the range 1 toBlake2b.MaxHashSize.
Constants
| Name | Description |
|---|---|
| MaxHashSize | The maximum size of a digest, in bytes (RFC 7693 section 2.1, nn). |
MaxHashSize
The maximum size of a digest, in bytes (RFC 7693 section 2.1, nn).
public const int MaxHashSize = 64