View Source xxh3 (xxh3 v0.3.5)
NIF bindings for XXH3 hash functions implemented in Rust
XXH3 is a new speed-optimized hash algorithm of the xxHash family of non-cryptographic hash functions, featuring:- Improved speed for both small and large inputs
- True 64-bit and 128-bit outputs
- SIMD acceleration
- Improved 32-bit viability
Speed analysis methodology is explained here:
https://fastcompression.blogspot.com/2019/03/presenting-xxh3.htmlLink to this section Summary
Functions
Returns 64-bit hash for the given Data
.
Returns 64-bit hash for the given Data
with Seed
value.
Returns 64-bit hash for the given Data
with a custom Secret
.
Returns 128-bit hash for the given Data
.
Returns 128-bit hash for the given Data
with Seed
value.
Returns 128-bit hash for the given Data
with a custom Secret
.
Creates a new 64-bit hasher with default secret.
Seed
.Creates a new 64-bit hasher with the given Secret
.
Link to this section Types
-opaque xxh3_ref()
Link to this section Functions
-spec digest(xxh3_ref()) -> non_neg_integer().
-spec hash64(binary()) -> non_neg_integer().
Returns 64-bit hash for the given Data
.
-spec hash64(binary(), non_neg_integer()) -> non_neg_integer().
Returns 64-bit hash for the given Data
with Seed
value.
Seed
value. While this operation is decently fast, note that it's not completely free.
-spec hash64_with_secret(binary(), binary()) -> non_neg_integer().
Returns 64-bit hash for the given Data
with a custom Secret
.
Secret
size *must* be large enough (>= 136 bytes). However, the quality of produced hash values depends on secret's entropy. Technically, the secret must look like a bunch of random bytes. Avoid "trivial" or structured data such as repeated sequences or a text document.
-spec hash128(binary()) -> non_neg_integer().
Returns 128-bit hash for the given Data
.
-spec hash128(binary(), non_neg_integer()) -> non_neg_integer().
Returns 128-bit hash for the given Data
with Seed
value.
hash64/2
for more details.
-spec hash128_with_secret(binary(), binary()) -> non_neg_integer().
Returns 128-bit hash for the given Data
with a custom Secret
.
hash64_with_secret/2
for more details.
-spec new() -> xxh3_ref().
Creates a new 64-bit hasher with default secret.
You can stream data to the returned object usingupdate/2
, and calculate intermediate hash values using digest/1
.
-spec new(non_neg_integer()) -> xxh3_ref().
Seed
.
-spec new_with_secret(binary()) -> xxh3_ref().
Creates a new 64-bit hasher with the given Secret
.
Secret
must be a binary of size 192 bytes.
-spec reset(xxh3_ref()) -> ok.
-spec update(xxh3_ref(), binary()) -> ok.