[−][src]Struct blake2b_simd::State
An incremental hasher for BLAKE2b.
To construct a State
with non-default parameters, see Params::to_state
.
Example
use blake2b_simd::{State, blake2b}; let mut state = blake2b_simd::State::new(); state.update(b"foo"); assert_eq!(blake2b(b"foo"), state.finalize()); state.update(b"bar"); assert_eq!(blake2b(b"foobar"), state.finalize());
Methods
impl State
[src]
pub fn new() -> Self
[src]
Equivalent to State::default()
or Params::default().to_state()
.
pub fn update(&mut self, input: &[u8]) -> &mut Self
[src]
Add input to the hash. You can call update
any number of times.
pub fn finalize(&self) -> Hash
[src]
Finalize the state and return a Hash
. This method is idempotent, and calling it multiple
times will give the same result. It's also possible to update
with more input in between.
pub fn set_last_node(&mut self, last_node: bool) -> &mut Self
[src]
Set a flag indicating that this is the last node of its level in a tree hash. This is
equivalent to Params::last_node
, except that it can be set at any time before calling
finalize
. That allows callers to begin hashing a node without knowing ahead of time
whether it's the last in its level. For more details about the intended use of this flag
the BLAKE2 spec.
pub fn count(&self) -> u128
[src]
Return the total number of bytes input so far.
Note that count
doesn't include the bytes of the key block, if any.
It's exactly the total number of input bytes fed to update
.
Trait Implementations
impl Default for State
[src]
impl Clone for State
[src]
ⓘImportant traits for Statefn clone(&self) -> State
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for State
[src]
impl Write for State
[src]
fn write(&mut self, buf: &[u8]) -> Result<usize>
[src]
fn flush(&mut self) -> Result<()>
[src]
fn write_vectored(&mut self, bufs: &[IoSlice]) -> Result<usize, Error>
1.36.0[src]
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
1.0.0[src]
fn write_fmt(&mut self, fmt: Arguments) -> Result<(), Error>
1.0.0[src]
fn by_ref(&mut self) -> &mut Self
1.0.0[src]
Auto Trait Implementations
impl Sync for State
impl Send for State
impl Unpin for State
impl RefUnwindSafe for State
impl UnwindSafe for State
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
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>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,