[][src]Struct kangarootwelve_xkcp::Hasher

pub struct Hasher(_);

An incremental hash state that can accept any number of writes.

Examples

// Hash an input incrementally.
let mut hasher = kangarootwelve_xkcp::Hasher::new();
hasher.update(b"foo");
hasher.update(b"bar");
hasher.update(b"baz");
assert_eq!(hasher.finalize(), kangarootwelve_xkcp::hash(b"foobarbaz"));

// Extended output. OutputReader also implements Read and Seek.
let mut output = [0; 1000];
let mut output_reader = hasher.finalize_xof();
output_reader.fill(&mut output);
assert_eq!(&output[..32], kangarootwelve_xkcp::hash(b"foobarbaz").as_bytes());

Implementations

impl Hasher[src]

pub fn new() -> Self[src]

Construct a new Hasher for the regular hash function.

pub fn update(&mut self, input: &[u8])[src]

Add input bytes to the hash state. You can call this any number of times, until the Hasher is finalized.

pub fn finalize(&mut self) -> Hash[src]

Finalize the hash state and return the Hash of the input. This method is equivalent to finalize_custom with an empty customization string.

You can only finalize a Hasher once. Additional calls to any of the finalize methods will panic.

pub fn finalize_custom(&mut self, customization: &[u8]) -> Hash[src]

Finalize the hash state using the given customization string and return the Hash of the input.

You can only finalize a Hasher once. Additional calls to any of the finalize methods will panic.

pub fn finalize_xof(&mut self) -> OutputReader[src]

Finalize the hash state and return an OutputReader, which can supply any number of output bytes. This method is equivalent to finalize_custom_xof with an empty customization string.

You can only finalize a Hasher once. Additional calls to any of the finalize methods will panic.

pub fn finalize_custom_xof(&mut self, customization: &[u8]) -> OutputReader[src]

Finalize the hash state and return an OutputReader, which can supply any number of output bytes.

You can only finalize a Hasher once. Additional calls to any of the finalize methods will panic.

Trait Implementations

impl Clone for Hasher[src]

impl Debug for Hasher[src]

impl Default for Hasher[src]

Auto Trait Implementations

impl RefUnwindSafe for Hasher

impl Send for Hasher

impl Sync for Hasher

impl Unpin for Hasher

impl UnwindSafe for Hasher

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.