[−][src]Struct kangarootwelve_xkcp::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
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,