Struct fog_crypto::hash::HashState [−][src]
A hasher that can incrementally take in data and produce a hash at any time.
Example
// Create a hash by feeding in bytes repeatedly let mut hash_state = HashState::new(); hash_state.update(b"I am the first part of a data sequence"); let hash_first = hash_state.hash(); // Produce a hash of just the first part hash_state.update(b"And I am their sibling, the second part of a data sequence"); let hash_full = hash_state.finalize(); // Consume the HashState println!("hash_first(Base58): {}", hash_first); println!("hash_full(Base58): {}", hash_full);
Implementations
impl HashState
[src]
pub fn new() -> HashState
[src]
Initialize a new hasher.
pub fn with_version(version: u8) -> Result<HashState, CryptoError>
[src]
Initialize a new hasher with a specific algorithm version. You should avoid this except when working through an upgrade process, where you may briefly need to support more than one version. Fails if the version isn’t supported.
pub fn version(&self) -> u8
[src]
Get the version of hash that this hasher will produce on completion.
pub fn update(&mut self, data: impl AsRef<[u8]>)
[src]
Update the hasher with new input data.
pub fn hash(&self) -> Hash
[src]
Get the hash of the data fed into the algorithm so far.
pub fn finalize(self) -> Hash
[src]
Finalize the hasher and produce a hash. Functions like hash()
but consumes the state.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for HashState
impl Send for HashState
impl Sync for HashState
impl Unpin for HashState
impl UnwindSafe for HashState
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,
pub 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> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub 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.
pub 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.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,