Struct mini_functions::hash::algorithms::bcrypt::Bcrypt
source · pub struct Bcrypt;
Expand description
Implementation of the Bcrypt hashing algorithm.
Bcrypt
is a struct that represents the Bcrypt hashing algorithm,
which is based on the Blowfish cipher and is particularly effective against brute-force attacks.
This struct implements the HashingAlgorithm
trait, providing a concrete implementation
for hashing passwords using the Bcrypt algorithm.
Features
- Computationally intensive, making brute-force attacks more difficult.
- Uses key stretching to make pre-computed attacks (like rainbow tables) less effective.
Examples
use hsh::models::hash_algorithm::HashingAlgorithm;
use hsh::algorithms::bcrypt::Bcrypt;
let password = "supersecret";
let salt = "randomsalt";
let hashed_password = Bcrypt::hash_password(password, salt).unwrap();
Trait Implementations§
source§impl<'de> Deserialize<'de> for Bcrypt
impl<'de> Deserialize<'de> for Bcrypt
source§fn deserialize<__D>(
__deserializer: __D
) -> Result<Bcrypt, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D
) -> Result<Bcrypt, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl HashingAlgorithm for Bcrypt
impl HashingAlgorithm for Bcrypt
source§fn hash_password(password: &str, _salt: &str) -> Result<Vec<u8>, String>
fn hash_password(password: &str, _salt: &str) -> Result<Vec<u8>, String>
Hashes a given password using the Bcrypt algorithm.
This method computes a hashed representation of the plaintext password
using the Bcrypt algorithm.
Note that the salt
parameter is not used in this implementation, as Bcrypt generates its own salt internally.
Parameters
password
: The plaintext password to be hashed._salt
: Unused in this implementation, provided for interface compatibility.
Returns
Returns a Result
containing the hashed password as a vector of bytes.
If hashing fails for some reason, returns a String
detailing the error.
source§impl Ord for Bcrypt
impl Ord for Bcrypt
source§impl PartialEq for Bcrypt
impl PartialEq for Bcrypt
source§impl PartialOrd for Bcrypt
impl PartialOrd for Bcrypt
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl Serialize for Bcrypt
impl Serialize for Bcrypt
source§fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl Copy for Bcrypt
impl Eq for Bcrypt
impl StructuralEq for Bcrypt
impl StructuralPartialEq for Bcrypt
Auto Trait Implementations§
impl RefUnwindSafe for Bcrypt
impl Send for Bcrypt
impl Sync for Bcrypt
impl Unpin for Bcrypt
impl UnwindSafe for Bcrypt
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