Rebex
Products Downloads Buy Support Contact
Show / Hide Table of Contents

Blake2b512.HashData Method

Namespace: Rebex.Security.Cryptography
Assembly: Rebex.Security.dll (version 7.0.9147)

HashData(Byte[], Byte[])

Computes a 512-bit (64-byte) hash using the BLAKE2b cryptographic hash and message authentication code (MAC) algorithm.

Declaration
public static byte[] HashData(byte[] key, byte[] source)
Parameters
Type Name Description
Byte[] key

Key to use in HMAC calculation.

The key must be a 0 - 64 bytes long array or null. When a null value is provided, the key is treated as an empty array. When the key is null or an empty array, the method will calculate a hash. When the key is 1 - 64 bytes long, the method will calculate a message authentication code (HMAC).

Byte[] source

An array that contains data to be hashed.

Returns
Type Description
Byte[]

The hash of the source.

Examples
// prepare data to be hashed
byte[] sourceBytes = GetSourceBytes();
// prepare the key (can be null)
byte[] keyBytes = GetKeyBytes();
// compute the hash;
// the 'hash' variable contains a 64-byte-long hash value
byte[] hash = Blake2b512.HashData(keyBytes, sourceBytes);

HashData(ArraySegment<Byte>, ArraySegment<Byte>)

Computes a 512-bit (64-byte) hash using the BLAKE2b cryptographic hash and message authentication code (MAC) algorithm.

Declaration
public static byte[] HashData(ArraySegment<byte> key, ArraySegment<byte> source)
Parameters
Type Name Description
ArraySegment<Byte> key

Key to use in HMAC calculation.

The key must be a 0 - 64 bytes long ArraySegment<T>. When the key is empty, the method will calculate a hash. When the key is 1 - 64 bytes long, the method will calculate a message authentication code (HMAC).

ArraySegment<Byte> source

An ArraySegment<T> that contains data to be hashed.

Returns
Type Description
Byte[]

The hash of the source.

Examples
// prepare data to be hashed
ArraySegment<byte> sourceArraySegment = GetSourceData();
// prepare the key (can be an empty ArraySegment)
ArraySegment<byte> keyArraySegment = GetKey();
// compute the hash;
// the 'hash' variable contains a 64-byte-long hash value
byte[] hash = Blake2b512.HashData(keyArraySegment, sourceArraySegment);

HashData(ArraySegment<Byte>, ArraySegment<Byte>, ArraySegment<Byte>)

Computes a 512-bit (64-byte) hash using the BLAKE2b cryptographic hash and message authentication code (MAC) algorithm.

Declaration
public static int HashData(ArraySegment<byte> key, ArraySegment<byte> source, ArraySegment<byte> destination)
Parameters
Type Name Description
ArraySegment<Byte> key

Key to use in HMAC calculation.

The key must be a 0 - 64 bytes long ArraySegment<T>. When the key is empty, the method will calculate a hash. When the key is 1 - 64 bytes long, the method will calculate a message authentication code (HMAC).

ArraySegment<Byte> source

An ArraySegment<T> that contains data to be hashed.

ArraySegment<Byte> destination

An ArraySegment<T> where the calculated hash will be stored. Must be at least 64 bytes long, otherwise an ArgumentException will be thrown.

Returns
Type Description
Int32

The number of bytes written to the destination. Always returns the hash size (64 bytes).

Examples
// prepare data to be hashed
ArraySegment<byte> sourceArraySegment = GetSourceData();
// prepare the key (can be an empty ArraySegment)
ArraySegment<byte> keyArraySegment = GetKey();
// prepare an ArraySegment which will receive the 64-byte long hash
ArraySegment<byte> outputHashArraySegment = new ArraySegment<byte>(new byte[64]);
// compute the 64-byte hash and store it into outputHashArraySegment;
// the hashSize variable will contain the value of 64 (hash size in bytes)
int hashSize = Blake2b512.HashData(keyArraySegment, sourceArraySegment, outputHashArraySegment);
In This Article
  • HashData(Byte[], Byte[])
  • HashData(ArraySegment<Byte>, ArraySegment<Byte>)
  • HashData(ArraySegment<Byte>, ArraySegment<Byte>, ArraySegment<Byte>)
© REBEX ČR s.r.o. Back to top
Privacy policy
Manage cookies