crypto.blake2b
Get BLAKE2b hash, optionally keyed.
📝Syntax
hexa_hash = crypto.blake2b(message)
hexa_hash = crypto.blake2b(message, key)
hexa_hash = crypto.blake2b(message, key, digestSize)
hexa_hash = crypto.blake2b(filename, key, digestSize, '-file')
📥Input Arguments
Parameter Description
message a uint8 vector (raw bytes) or a character vector (UTF-8 bytes): content to hash.
filename a string: existing file whose raw bytes are hashed.
key a uint8 vector (raw bytes) or a character vector (UTF-8 bytes) of at most 64 bytes, or [] for an unkeyed hash (default).
digestSize an integer between 1 and 64: digest length in bytes (default: 64).
'-file' first argument is a filename (always the last argument).
📤Output Arguments
Parameter Description
hexa_hash a character vector: 2 * digestSize lowercase hexadecimal characters.
📄Description

crypto.blake2b computes a BLAKE2b digest (RFC 7693): a fast cryptographic hash with a configurable output size. With a key it acts as a message authentication code without the HMAC construction.

💡Examples
R = crypto.blake2b('abc')
R = crypto.blake2b('abc', [], 20)
R = crypto.blake2b('abc', 'my secret key', 32)
hash a file
filename = [tempdir(), 'blake2b_example.txt'];
filewrite(filename, 'abc');
R = crypto.blake2b(filename, [], 64, '-file')
🔗See Also
crypto.sha512crypto.hmaccrypto.argon2
Used Functions
Monocypher
📚Bibliography
https://www.rfc-editor.org/rfc/rfc7693, https://monocypher.org/
🕔Version History
Version Description
2.0.0 initial version
Edit this page on GitHub