Module xxh3

NIF bindings for XXH3 hash functions implemented in Rust.

Description

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:

Speed analysis methodology is explained here:

https://fastcompression.blogspot.com/2019/03/presenting-xxh3.html

Function Index

hash128/1Returns 128-bit hash for the given Data.
hash128/2Returns 128-bit hash for the given Data with Seed value.
hash128_with_secret/2Returns 128-bit hash for the given Data with a custom Secret.
hash64/1Returns 64-bit hash for the given Data.
hash64/2Returns 64-bit hash for the given Data with Seed value.
hash64_with_secret/2Returns 64-bit hash for the given Data with a custom Secret.

Function Details

hash128/1

hash128(Data::binary()) -> non_neg_integer()

Returns 128-bit hash for the given Data.

This is default 128-bit variant, using default secret and default seed of 0.

hash128/2

hash128(Data::binary(), Seed::non_neg_integer()) -> non_neg_integer()

Returns 128-bit hash for the given Data with Seed value.

See hash64/2 for more details.

hash128_with_secret/2

hash128_with_secret(Data::binary(), Secret::binary()) -> non_neg_integer()

Returns 128-bit hash for the given Data with a custom Secret.

See hash64_with_secret/2 for more details.

hash64/1

hash64(Data::binary()) -> non_neg_integer()

Returns 64-bit hash for the given Data.

This is default 64-bit variant, using default secret and default seed of 0. It's the fastest variant.

hash64/2

hash64(Data::binary(), Seed::non_neg_integer()) -> non_neg_integer()

Returns 64-bit hash for the given Data with Seed value.

This variant generates a custom secret on the fly based on default secret altered using the Seed value. While this operation is decently fast, note that it's not completely free.

hash64_with_secret/2

hash64_with_secret(Data::binary(), Secret::binary()) -> non_neg_integer()

Returns 64-bit hash for the given Data with a custom Secret.

It's possible to provide any binary as a "secret" to generate the hash. This makes it more difficult for an external actor to prepare an intentional collision. The main condition is that 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.


Generated by EDoc