pub struct TargetHashAndHashFunction<T: CrackTarget> { /* private fields */ }Expand description
Abstraction over a hashing algorithm and the target hash that needs to be cracked.
T is of type CrackTarget. This generic struct exists so that hashes of type
CrackTarget can be checked independent of the hashing algorithm. This is
more efficient than transforming every hash to a string and compare the hash
string representations afterwards.
Implementations§
Source§impl<T: CrackTarget> TargetHashAndHashFunction<T>
impl<T: CrackTarget> TargetHashAndHashFunction<T>
Sourcepub fn new(
target_hash: TargetHashInput<'_>,
hash_fn: fn(&str) -> T,
hash_str_repr_to_hash_type_fn: fn(hash_as_string: &str) -> T,
hash_type_to_str_repr_fn: fn(hash: &T) -> String,
) -> Self
pub fn new( target_hash: TargetHashInput<'_>, hash_fn: fn(&str) -> T, hash_str_repr_to_hash_type_fn: fn(hash_as_string: &str) -> T, hash_type_to_str_repr_fn: fn(hash: &T) -> String, ) -> Self
Constructor that takes a hashing function and a target hash.
§Parameters
target_hashString representation of the target hash we want to crack. This is usually the hex string representation of a sha256 hash or so.hash_fnTransforms a plain input password/guess of typestrto the target hash. This is the hashing function.hash_str_repr_to_hash_type_fnFunction that can take the argumenttarget_hashand transform it to the target hashing type. This usually transforms the hex string that represents the hash to bytes in memory.hash_type_to_str_repr_fnFunction that transform the hash type to a string representation. Usually, this will return a hex string that represents the hash.
Source§impl<T: CrackTarget> TargetHashAndHashFunction<T>
impl<T: CrackTarget> TargetHashAndHashFunction<T>
Sourcepub fn hash_str_repr_to_hash_type(&self, hash_as_string: &str) -> T
pub fn hash_str_repr_to_hash_type(&self, hash_as_string: &str) -> T
Transforms the (hex) string representation into the type the hash implementation uses to represent hashes.
Sourcepub fn target_hash(&self) -> &T
pub fn target_hash(&self) -> &T
Returns the target hash that we want to crack.
Sourcepub fn hash_type_to_str_repr(&self, hash: &T) -> String
pub fn hash_type_to_str_repr(&self, hash: &T) -> String
Returns a (hex) string representation of the hash.
Sourcepub fn hash_matches(&self, input: &str) -> bool
pub fn hash_matches(&self, input: &str) -> bool
Hashes the input value and returns if it equals the target hash. If so, the hash got cracked.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for TargetHashAndHashFunction<T>where
T: Freeze,
impl<T> RefUnwindSafe for TargetHashAndHashFunction<T>where
T: RefUnwindSafe,
impl<T> Send for TargetHashAndHashFunction<T>
impl<T> Sync for TargetHashAndHashFunction<T>
impl<T> Unpin for TargetHashAndHashFunction<T>where
T: Unpin,
impl<T> UnwindSafe for TargetHashAndHashFunction<T>where
T: UnwindSafe,
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