Expand description
§Short-input hashing
Implements libsodium’s SipHash-2-4 function for short inputs. It produces a compact, keyed hash that can protect hash tables against attacker-chosen collision patterns.
This function is intended for short, keyed inputs. It is not a
general-purpose hash or an encryption primitive. Use
crate::classic::crypto_auth for message authentication, or
crate::classic::crypto_generichash for general-purpose hashing.
Treat the key as secret and generate it randomly. See the libsodium documentation for details.
§Classic API example
use dryoc::classic::crypto_shorthash::*;
use dryoc::rng::copy_randombytes;
// Generate a random key
let key = crypto_shorthash_keygen();
// Generate some random input data
let mut input = vec![0u8; 69];
copy_randombytes(&mut input);
// Compute the hash, put result into `output`
let mut output = Hash::default();
crypto_shorthash(&mut output, &input, &key);Functions§
- crypto_
shorthash - Computes a short input hash for
inputandkey, placing the result intooutput, using SipHash-2-4. - crypto_
shorthash_ keygen - Generates a random key for short input hashing.