folly::crypto::Blake2xb

An implementation of the BLAKE2x XOF (extendable output function) hash function using BLAKE2b as the underlying hash. This hash function can produce cryptographic hashes of arbitrary length (between 1 and 2^32 - 2 bytes) from inputs of arbitrary size. Like BLAKE2b, it can be keyed, and can accept optional salt and personlization parameters.

Synopsis

Declared in <folly/crypto/Blake2xb.h>

class Blake2xb;

Description

Note that if you need to compute hashes between 16 and 64 bytes in length, you should use Blake2b instead - it's more efficient and you will have an easier time interoperating with other languages, since implementations of Blake2b are more common than implementations of Blake2xb. You can generate a blake2b hash using the following functions from libsodium:

  • crypto_generichash_blake2b()

  • crypto_generichash_blake2b_salt_personal()

Member Functions

NameDescription
Blake2xb [constructor]Constructors
~Blake2xb [destructor]Destroys the instance and clears its internal state.
finish Computes the final hash and stores it in the given output. The value of out.size() MUST equal the outputLength parameter that was given to the last init() call, except when the outputLength parameter was kUnknownOutputLength.
init Initializes the digest object. This must be called after a new instance is constructed and before update() is called. It can also be called on a previously-used instance to reset its internal state and reuse it for a new hash computation.
update Hashes some more input data.

Static Member Functions

NameDescription
hash Convenience function, use this if you are hashing a single input buffer, the output length is known in advance, and the output data is allocated and ready to accept the hash value.

Static Data Members

NameDescription
kMaxOutputLength Maximum output hash size, if it is known in advance.
kMinOutputLength Minimum output hash size, if it is known in advance.
kUnknownOutputLength If the amount of output data desired is not known in advance, use this constant as the outputLength parameter to init().