pub struct Sha224Hasher(/* private fields */);Expand description
Sha224Hasher is a type that provides the SHA-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 Sha224Hasher 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 Sha1Hasher with both Hash and Hasher, and from where the difference
comes from:
let data = b"hello";
// Using Hash
let mut sha224hasher = Sha224Hasher::default();
data.hash(&mut sha224hasher);
let result_via_hash = sha224hasher.finish();
// Using Hasher
let mut sha224hasher = Sha224Hasher::default();
sha224hasher.write(data);
let result_via_hasher = sha224hasher.finish();
// Simulating the Hash inners
let mut sha224hasher = Sha224Hasher::default();
sha224hasher.write_usize(data.len());
sha224hasher.write(data);
let simulated_hash_result = sha224hasher.finish();
assert_ne!(result_via_hash, result_via_hasher);
assert_eq!(result_via_hash, simulated_hash_result);Trait Implementations§
Source§impl Clone for Sha224Hasher
impl Clone for Sha224Hasher
Source§fn clone(&self) -> Sha224Hasher
fn clone(&self) -> Sha224Hasher
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Sha224Hasher
impl Debug for Sha224Hasher
Source§impl Default for Sha224Hasher
impl Default for Sha224Hasher
Source§fn default() -> Sha224Hasher
fn default() -> Sha224Hasher
Source§impl From<Sha224Hasher> for Sha224State
impl From<Sha224Hasher> for Sha224State
Source§fn from(value: Sha224Hasher) -> Sha224State
fn from(value: Sha224Hasher) -> Sha224State
Source§impl From<Sha224State> for Sha224Hasher
impl From<Sha224State> for Sha224Hasher
Source§fn from(value: Sha224State) -> Sha224Hasher
fn from(value: Sha224State) -> Sha224Hasher
Source§impl Hash for Sha224Hasher
impl Hash for Sha224Hasher
Source§impl Hasher for Sha224Hasher
impl Hasher for Sha224Hasher
Source§fn write(&mut self, bytes: &[u8])
fn write(&mut self, bytes: &[u8])
Write a byte array to the hasher.
This hasher can digest up to u64::MAX bytes. If more bytes are written, the hasher will panic.
1.26.0 · Source§fn write_u128(&mut self, i: u128)
fn write_u128(&mut self, i: u128)
u128 into this hasher.1.3.0 · Source§fn write_usize(&mut self, i: usize)
fn write_usize(&mut self, i: usize)
usize into this hasher.1.26.0 · Source§fn write_i128(&mut self, i: i128)
fn write_i128(&mut self, i: i128)
i128 into this hasher.1.3.0 · Source§fn write_isize(&mut self, i: isize)
fn write_isize(&mut self, i: isize)
isize into this hasher.Source§fn write_length_prefix(&mut self, len: usize)
fn write_length_prefix(&mut self, len: usize)
hasher_prefixfree_extras)