pub struct Xxh3_64 { /* private fields */ }Expand description
XXH3 64-bit hash.
A fast non-cryptographic hash using the XXH3 algorithm. Supports an
optional u64 seed and an optional custom 192-byte secret.
Incremental hashing (update) produces exactly the same
value as one-shot hashing (checksum, or the
xxh3_64 free function), for any input length and any split of the input
across update calls. No input can make it panic.
When the std feature is enabled (the default), the long-input path uses
AVX2 / AVX-512 (x86) or NEON (aarch64) kernels selected at runtime; with
no_std, the kernels are selected at compile time from the enabled target
features.
§Security
XXH3 is not a cryptographic hash: it must not be used to authenticate messages, derive keys, or store passwords, and a seed or a custom secret is not a security boundary. It is also not collision-resistant against deliberate attacks; do not use it to defend a hash table against attacker-chosen keys (hash flooding).
§Example
use xxhash::{Xxh3_64, Checksum};
let hash = Xxh3_64::checksum(b"hello world");Implementations§
Source§impl Xxh3_64
impl Xxh3_64
Sourcepub const fn with_seed(seed: u64) -> Self
pub const fn with_seed(seed: u64) -> Self
Create a new XXH3-64 hasher with the given seed.
A zero seed is equivalent to the default, unseeded hasher.
Sourcepub const fn with_secret(secret: [u8; 192]) -> Self
pub const fn with_secret(secret: [u8; 192]) -> Self
Create a new XXH3-64 hasher with a custom 192-byte secret (seed = 0).
Sourcepub const fn with_seed_and_secret(seed: u64, secret: [u8; 192]) -> Self
pub const fn with_seed_and_secret(seed: u64, secret: [u8; 192]) -> Self
Create a new XXH3-64 hasher with a custom seed and secret.
This matches the reference XXH3_64bits_withSecretandSeed() contract:
the seed is used for inputs of up to 240 bytes (with the default
secret), while the custom secret is used — and the seed is ignored —
for longer inputs.