Blake2b512.HashData Method
Namespace: Rebex.Security.Cryptography
Assembly: Rebex.Security.dll (version 7.0.9083)
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 |
Byte[] | source | An array that contains data to be hashed. |
Returns
Type | Description |
---|---|
Byte[] | The hash of the |
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 |
ArraySegment<Byte> | source | An ArraySegment<T> that contains data to be hashed. |
Returns
Type | Description |
---|---|
Byte[] | The hash of the |
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 |
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 |
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);