Struct rs_sha512_224::Sha512_224Hasher
source · pub struct Sha512_224Hasher(_);
Expand description
Sha512_224Hasher
is a type that provides the SHA-512/224 hashing algorithm in RustyShield.
A “Hasher” in the context of cryptographic hashing refers to the object that manages the process of converting input data into a fixed-size sequence of bytes. The Hasher is responsible for maintaining the internal state of the hashing process and providing methods to add more data and retrieve the resulting hash.
The Sha512_224Hasher
struct adheres to Rust’s Hasher
trait, enabling you to use it interchangeably with other hashers
in Rust. It can be used anywhere a type implementing Hasher
is required.
Examples
The following examples demonstrate using Sha512_224Hasher
with both Hash
and Hasher
, and how the results can differ:
let data = b"hello";
// Using Hash
let mut sha512_224hasher = Sha512_224Hasher::default();
data.hash(&mut sha512_224hasher);
let result_via_hash = sha512_224hasher.finish();
// Using Hasher
let mut sha512_224hasher = Sha512_224Hasher::default();
sha512_224hasher.write(data);
let result_via_hasher = sha512_224hasher.finish();
// Simulating the Hash inners
let mut sha512_224hasher = Sha512_224Hasher::default();
sha512_224hasher.write_usize(data.len());
sha512_224hasher.write(data);
let simulated_hash_result = sha512_224hasher.finish();
assert_ne!(result_via_hash, result_via_hasher);
assert_eq!(result_via_hash, simulated_hash_result);
Trait Implementations§
source§impl Clone for Sha512_224Hasher
impl Clone for Sha512_224Hasher
source§fn clone(&self) -> Sha512_224Hasher
fn clone(&self) -> Sha512_224Hasher
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for Sha512_224Hasher
impl Debug for Sha512_224Hasher
source§impl Default for Sha512_224Hasher
impl Default for Sha512_224Hasher
source§fn default() -> Sha512_224Hasher
fn default() -> Sha512_224Hasher
Returns the “default value” for a type. Read more
source§impl From<Sha512_224Hasher> for Sha512_224State
impl From<Sha512_224Hasher> for Sha512_224State
source§fn from(value: Sha512_224Hasher) -> Self
fn from(value: Sha512_224Hasher) -> Self
Converts to this type from the input type.
source§impl From<Sha512_224State> for Sha512_224Hasher
impl From<Sha512_224State> for Sha512_224Hasher
source§fn from(value: Sha512_224State) -> Self
fn from(value: Sha512_224State) -> Self
Converts to this type from the input type.
source§impl Hash for Sha512_224Hasher
impl Hash for Sha512_224Hasher
source§impl Hasher for Sha512_224Hasher
impl Hasher for Sha512_224Hasher
1.26.0 · source§fn write_u128(&mut self, i: u128)
fn write_u128(&mut self, i: u128)
Writes a single
u128
into this hasher.1.3.0 · source§fn write_usize(&mut self, i: usize)
fn write_usize(&mut self, i: usize)
Writes a single
usize
into this hasher.1.26.0 · source§fn write_i128(&mut self, i: i128)
fn write_i128(&mut self, i: i128)
Writes a single
i128
into this hasher.1.3.0 · source§fn write_isize(&mut self, i: isize)
fn write_isize(&mut self, i: isize)
Writes a single
isize
into this hasher.source§fn write_length_prefix(&mut self, len: usize)
fn write_length_prefix(&mut self, len: usize)
🔬This is a nightly-only experimental API. (
hasher_prefixfree_extras
)Writes a length prefix into this hasher, as part of being prefix-free. Read more
source§impl HasherContext<BYTES_LEN> for Sha512_224Hasher
impl HasherContext<BYTES_LEN> for Sha512_224Hasher
source§impl PartialEq<Sha512_224Hasher> for Sha512_224Hasher
impl PartialEq<Sha512_224Hasher> for Sha512_224Hasher
source§fn eq(&self, other: &Sha512_224Hasher) -> bool
fn eq(&self, other: &Sha512_224Hasher) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.impl Eq for Sha512_224Hasher
impl StructuralEq for Sha512_224Hasher
impl StructuralPartialEq for Sha512_224Hasher
Auto Trait Implementations§
impl RefUnwindSafe for Sha512_224Hasher
impl Send for Sha512_224Hasher
impl Sync for Sha512_224Hasher
impl Unpin for Sha512_224Hasher
impl UnwindSafe for Sha512_224Hasher
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