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<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::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 PartialOrd for Bcrypt
impl PartialOrd for Bcrypt
impl Copy for Bcrypt
impl Eq for Bcrypt
impl StructuralPartialEq for Bcrypt
Auto Trait Implementations§
impl Freeze for Bcrypt
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