pub struct GenericHash<const KEY_LENGTH: usize, const OUTPUT_LENGTH: usize> { /* private fields */ }
Expand description

Provides a generic hash function implementation based on Blake2b. Compatible with libsodium’s generic hash.

Implementations§

Returns a new hasher instance, with key.

Updates the hasher state from input.

Computes and returns the final hash value.

Computes and returns the final hash value as a Vec. Provided for convenience.

Onet-time interface for the generic hash function. Computes the hash for input with optional key. The output length is determined by the type signature of Output.

Example
use base64::encode;
use dryoc::generichash::{GenericHash, Hash};

let output: Hash =
    GenericHash::hash(b"hello", Some(b"a very secret key")).expect("hash failed");

assert_eq!(
    encode(&output),
    "AECDe+XJsB6nOkbCsbS/OPXdzpcRm3AolW/Bg1LFY9A="
);

Convenience wrapper for GenericHash::hash.

Returns an instance of GenericHash with the default output and key length parameters.

Hashes input using key, with the default length parameters. Provided for convenience.

Hashes input using key, with the default length parameters, returning a Vec. Provided for convenience.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.