pub struct Sha3_512State { /* private fields */ }
Expand description
Sha3_512State
represents the state of a SHA3-512 hashing process.
It maintains the intermediate hash computations. It’s crucial to understand that initiating a hashing process from an
arbitrary Sha3_512State
doesn’t equate to resuming the original process that yielded that state. Instead, it
commences a new hashing process with a distinct set of initial values.
Thus, a Sha3_512State
derived from a Sha3_512Hasher
should not be utilized with the intention of continuing
the hashing operation from where it left off in the original Sha3_512Hasher
. It merely provides a snapshot of a particular
stage in the process, rather than a mechanism to continue the process.
§Example
This example demonstrates how to persist the state of a SHA3-512 hash operation:
let hello = b"hello";
let world = b" world";
let default_sha3_512state = Sha3_512State::default();
let mut default_sha3_512hasher = default_sha3_512state.build_hasher();
default_sha3_512hasher.write(hello);
let intermediate_state: Sha3_512State = default_sha3_512hasher.clone().into();
default_sha3_512hasher.write(world);
let mut from_sha3_512state: Sha3_512Hasher = intermediate_state.into();
from_sha3_512state.write(world);
let default_hello_world_result = default_sha3_512hasher.finish();
let from_arbitrary_state_result = from_sha3_512state.finish();
assert_ne!(default_hello_world_result, from_arbitrary_state_result);
§Note
In this example, even though the internal states are the same between default_sha3_512hasher
and from_sha3_512state
before the Hasher::finish
call, the results differ due to from_sha3_512state
starting with an empty
pad while the default_sha3_512hasher
’s pad is already populated with b"hello"
.
Trait Implementations§
Source§impl BuildHasher for Sha3_512State
impl BuildHasher for Sha3_512State
Source§type Hasher = Sha3_512Hasher
type Hasher = Sha3_512Hasher
Source§fn build_hasher(&self) -> <Sha3_512State as BuildHasher>::Hasher
fn build_hasher(&self) -> <Sha3_512State as BuildHasher>::Hasher
Source§impl Clone for Sha3_512State
impl Clone for Sha3_512State
Source§fn clone(&self) -> Sha3_512State
fn clone(&self) -> Sha3_512State
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more