libsodium_crypto_shorthash (libsodium v3.0.1)
View SourceKeyed hashing of short inputs with the default construction, currently
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.
Key = libsodium_crypto_shorthash:keygen(),
Hash = libsodium_crypto_shorthash:crypto_shorthash(<<"short input">>, Key),
8 = byte_size(Hash),
Hash = libsodium_crypto_shorthash_siphash24:crypto_shorthash_siphash24(<<"short input">>, Key).
Summary
Functions
Return crypto_shorthash_bytes(), in bytes.
Hash In under the keybytes/0 byte key K, returning bytes/0 bytes.
Return crypto_shorthash_keybytes(), in bytes.
Generate a random keybytes/0 byte key.
Return crypto_shorthash_primitive() as an atom.
Types
Functions
-spec bytes() -> Result when Result :: 8.
Return crypto_shorthash_bytes(), in bytes.
Hash In under the keybytes/0 byte key K, returning bytes/0 bytes.
-spec keybytes() -> Result when Result :: 16.
Return crypto_shorthash_keybytes(), in bytes.
-spec keygen() -> Result when Result :: k().
Generate a random keybytes/0 byte key.
-spec primitive() -> Result when Result :: siphash24.
Return crypto_shorthash_primitive() as an atom.