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 PartialOrd for Bcrypt
impl PartialOrd for Bcrypt
Source§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 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FromBase64 for Twhere
T: for<'de> Deserialize<'de>,
impl<T> FromBase64 for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more