Sha3_512State

Struct Sha3_512State 

Source
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

Source§

type Hasher = Sha3_512Hasher

Type of the hasher that will be created.
Source§

fn build_hasher(&self) -> <Sha3_512State as BuildHasher>::Hasher

Creates a new hasher. Read more
1.71.0 · Source§

fn hash_one<T>(&self, x: T) -> u64
where T: Hash, Self: Sized, Self::Hasher: Hasher,

Calculates the hash of a single value. Read more
Source§

impl BytesLen for Sha3_512State

Source§

impl Clone for Sha3_512State

Source§

fn clone(&self) -> Sha3_512State

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Sha3_512State

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for Sha3_512State

Source§

fn default() -> Sha3_512State

Returns the “default value” for a type. Read more
Source§

impl ExtendedOutputFunction<rs_sha3_512::::sha3_512state::{impl#0}::{constant#0}> for Sha3_512State

Source§

fn squeeze_u64(&self) -> u64

Source§

fn squeeze(&mut self) -> [u8; 64]

Squeezes the output data from the sponge
Source§

impl From<Sha3_512Hasher> for Sha3_512State

Source§

fn from(value: Sha3_512Hasher) -> Sha3_512State

Converts to this type from the input type.
Source§

impl From<Sha3_512State> for Sha3_512Hasher

Source§

fn from(value: Sha3_512State) -> Sha3_512Hasher

Converts to this type from the input type.
Source§

impl Hash for Sha3_512State

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl HashAlgorithm for Sha3_512State

Source§

type Padding = GenericPad<KeccakU128Size, rs_sha3_512::::sha3_512state::{impl#4}::Padding::{constant#1}, 6>

Source§

type Output = ByteArrayWrapper<rs_sha3_512::::sha3_512state::{impl#4}::Output::{constant#0}>

Source§

fn hash_block(&mut self, bytes: &[u8])

Source§

fn state_to_u64(&self) -> u64

Source§

impl PartialEq for Sha3_512State

Source§

fn eq(&self, other: &Sha3_512State) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for Sha3_512State

Source§

impl StructuralPartialEq for Sha3_512State

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.