pub struct GeneralSipHash<const C: u32, const D: u32> { /* private fields */ }Expand description
Implementation of the SipHash algorithm.
This algorithm is resistant to various hash attacks when C >= 2 and D >= 4.
§Notes
The HashFunction implementation returns values in little-endian order,
and thus is cross-platform (with slightly better performance on little-endian platforms).
This algorithm is an implementation of the “SipHash: a fast short-input PRF” paper by Jean-Philippe Aumasson and Daniel J. Bernstein.
Implementations§
Source§impl<const C: u32, const D: u32> GeneralSipHash<C, D>
impl<const C: u32, const D: u32> GeneralSipHash<C, D>
Sourcepub const fn for_array_key(key: &[u8; 16]) -> Self
pub const fn for_array_key(key: &[u8; 16]) -> Self
Creates a new GeneralSipHash instance from a given array key.
Sourcepub const fn for_slice_key(key: &[u8]) -> Self
pub const fn for_slice_key(key: &[u8]) -> Self
Creates a new GeneralSipHash instance from a given slice.
§Panics
If the key is not exactly 16 bytes long, this function will panic.
Sourcepub const fn for_keys(key0: u64, key1: u64) -> Self
pub const fn for_keys(key0: u64, key1: u64) -> Self
Creates a new GeneralSipHash instance from a key pair.
Sourcepub const fn update_const(&mut self, data: &[u8])
pub const fn update_const(&mut self, data: &[u8])
Updates the underlying state with the given block.
§Panics
If the length of the block exceeds u32::MAX.
Sourcepub const fn result_const(&self) -> u64
pub const fn result_const(&self) -> u64
Calculates the final hash value.
This function does not update the internal state, and thus
SipHash can still be used afterwards.
Trait Implementations§
Source§impl<const C: u32, const D: u32> HashFunction for GeneralSipHash<C, D>
impl<const C: u32, const D: u32> HashFunction for GeneralSipHash<C, D>
type Output = [u8; 8]
Source§fn update(&mut self, data: impl AsRef<[u8]>)
fn update(&mut self, data: impl AsRef<[u8]>)
HashFunction with given data.Source§fn write_result(&self, output: &mut Self::Output)
fn write_result(&self, output: &mut Self::Output)
Source§fn result(&self) -> Self::Output
fn result(&self) -> Self::Output
HashFunction::write_result that returns the hash
instead of writing it to output parameter.Source§impl<const C: u32, const D: u32> Hasher for GeneralSipHash<C, D>
impl<const C: u32, const D: u32> Hasher for GeneralSipHash<C, D>
1.26.0 · Source§fn write_u128(&mut self, i: u128)
fn write_u128(&mut self, i: u128)
u128 into this hasher.1.3.0 · Source§fn write_usize(&mut self, i: usize)
fn write_usize(&mut self, i: usize)
usize into this hasher.1.26.0 · Source§fn write_i128(&mut self, i: i128)
fn write_i128(&mut self, i: i128)
i128 into this hasher.1.3.0 · Source§fn write_isize(&mut self, i: isize)
fn write_isize(&mut self, i: isize)
isize into this hasher.Source§fn write_length_prefix(&mut self, len: usize)
fn write_length_prefix(&mut self, len: usize)
hasher_prefixfree_extras)