libsodium_crypto_shorthash_siphash24 (libsodium v3.0.1)
View SourceKeyed hashing of short inputs with SipHash-2-4, producing bytes/0
byte (64-bit) outputs under a keybytes/0 byte secret key.
It is designed for hash tables, Bloom filters, and similar structures
where an attacker must not be able to predict collisions. It is not a
general-purpose or collision-resistant cryptographic hash; use
libsodium_crypto_generichash for that. Keys can be generated with
libsodium_crypto_shorthash:keygen/0.
Key = libsodium_randombytes:buf(libsodium_crypto_shorthash_siphash24:keybytes()),
Hash = libsodium_crypto_shorthash_siphash24:crypto_shorthash_siphash24(<<"short input">>, Key),
8 = byte_size(Hash),
Hash = libsodium_crypto_shorthash_siphash24:crypto_shorthash_siphash24(<<"short input">>, Key).
Summary
Types
A crypto_shorthash_siphash24_KEYBYTES (16-byte) binary.
A crypto_shorthash_siphash24_BYTES (8-byte) binary.
Functions
Return crypto_shorthash_siphash24_bytes(), in bytes.
Hash In under the keybytes/0 byte key K, returning bytes/0 bytes.
Return crypto_shorthash_siphash24_keybytes(), in bytes.
Types
Functions
-spec bytes() -> Result when Result :: 8.
Return crypto_shorthash_siphash24_bytes(), in bytes.
-spec crypto_shorthash_siphash24(In, K) -> Result when In :: binary(), K :: k(), Result :: out() | -1.
Hash In under the keybytes/0 byte key K, returning bytes/0 bytes.
-spec keybytes() -> Result when Result :: 16.
Return crypto_shorthash_siphash24_keybytes(), in bytes.