Skip to main content

GeneralSipHash

Struct GeneralSipHash 

Source
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>

Source

pub const fn for_array_key(key: &[u8; 16]) -> Self

Creates a new GeneralSipHash instance from a given array key.

Source

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.

Source

pub const fn for_keys(key0: u64, key1: u64) -> Self

Creates a new GeneralSipHash instance from a key pair.

Source

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.

Source

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>

Source§

type Output = [u8; 8]

Source§

fn update(&mut self, data: impl AsRef<[u8]>)

Updates the internal state of the HashFunction with given data.
Source§

fn write_result(&self, output: &mut Self::Output)

Writes the final result to the output passed as ref parameter.
Source§

fn result(&self) -> Self::Output

A wrapper around 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>

Source§

fn finish(&self) -> u64

Returns the hash value for the values written so far. Read more
Source§

fn write(&mut self, bytes: &[u8])

Writes some data into this Hasher. Read more
1.3.0 · Source§

fn write_u8(&mut self, i: u8)

Writes a single u8 into this hasher.
1.3.0 · Source§

fn write_u16(&mut self, i: u16)

Writes a single u16 into this hasher.
1.3.0 · Source§

fn write_u32(&mut self, i: u32)

Writes a single u32 into this hasher.
1.3.0 · Source§

fn write_u64(&mut self, i: u64)

Writes a single u64 into this hasher.
1.26.0 · Source§

fn write_u128(&mut self, i: u128)

Writes a single u128 into this hasher.
1.3.0 · Source§

fn write_usize(&mut self, i: usize)

Writes a single usize into this hasher.
1.3.0 · Source§

fn write_i8(&mut self, i: i8)

Writes a single i8 into this hasher.
1.3.0 · Source§

fn write_i16(&mut self, i: i16)

Writes a single i16 into this hasher.
1.3.0 · Source§

fn write_i32(&mut self, i: i32)

Writes a single i32 into this hasher.
1.3.0 · Source§

fn write_i64(&mut self, i: i64)

Writes a single i64 into this hasher.
1.26.0 · Source§

fn write_i128(&mut self, i: i128)

Writes a single i128 into this hasher.
1.3.0 · Source§

fn write_isize(&mut self, i: isize)

Writes a single isize into this hasher.
Source§

fn write_length_prefix(&mut self, len: usize)

🔬This is a nightly-only experimental API. (hasher_prefixfree_extras)
Writes a length prefix into this hasher, as part of being prefix-free. Read more
Source§

fn write_str(&mut self, s: &str)

🔬This is a nightly-only experimental API. (hasher_prefixfree_extras)
Writes a single str into this hasher. Read more
Source§

impl<const C: u32, const D: u32> ReprC for GeneralSipHash<C, D>

Source§

const CHECK: ()

This field is used for const checks only.
Source§

impl<const C: u32, const D: u32> Send for GeneralSipHash<C, D>

Source§

impl<const C: u32, const D: u32> Sync for GeneralSipHash<C, D>

Auto Trait Implementations§

§

impl<const C: u32, const D: u32> Freeze for GeneralSipHash<C, D>

§

impl<const C: u32, const D: u32> RefUnwindSafe for GeneralSipHash<C, D>

§

impl<const C: u32, const D: u32> Unpin for GeneralSipHash<C, D>

§

impl<const C: u32, const D: u32> UnsafeUnpin for GeneralSipHash<C, D>

§

impl<const C: u32, const D: u32> UnwindSafe for GeneralSipHash<C, D>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.