Skip to main content

crypto_generichash_final

Function crypto_generichash_final 

Source
pub fn crypto_generichash_final(
    state: GenericHashState,
    output: &mut [u8],
) -> Result<(), Error>
Expand description

Finalizes the hash computation, copying the result into output, whose length should equal outlen from the call to crypto_generichash_init.

As in libsodium, a different length is not rejected: output receives its length’s worth (1 to 64 bytes) of the BLAKE2b chaining value computed for the init length, so a shorter output truncates the digest and a longer one appends chaining-value bytes that are not part of it.

Equivalent to libsodium’s crypto_generichash_final

§Errors

Returns an error if output is empty or longer than 64 bytes, lengths for which libsodium aborts.