Struct fog_crypto::hash::HashState
source · pub struct HashState { /* private fields */ }
Expand description
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§
source§impl HashState
impl HashState
sourcepub fn with_version(version: u8) -> Result<HashState, CryptoError>
pub fn with_version(version: u8) -> Result<HashState, CryptoError>
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.
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§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more