pub struct BcryptParams {
pub cost: u32,
}Expand description
Parameters for bcrypt key derivation.
The cost factor controls the number of iterations (2^cost).
Higher cost means slower hashing.
Fields§
§cost: u32Cost factor (must be in range [4, 31]).
Implementations§
Source§impl BcryptParams
impl BcryptParams
Sourcepub fn new(cost: u32) -> Result<Self, CryptoError>
pub fn new(cost: u32) -> Result<Self, CryptoError>
Create new parameters, returning an error if cost is out of range.
Valid range: 4 <= cost <= 31.
§Errors
Returns CryptoError::BadInput if cost < 4 or cost > 31.
Sourcepub fn interactive() -> Self
pub fn interactive() -> Self
Interactive login preset (cost = 10).
Suitable for online authentication; targets ~100 ms on modern hardware.
Sourcepub fn moderate() -> Self
pub fn moderate() -> Self
Moderate preset (cost = 12).
Balanced between interactive and sensitive use-cases.
Sourcepub fn validate(&self) -> Result<(), CryptoError>
pub fn validate(&self) -> Result<(), CryptoError>
Validate that the cost factor is within the allowed range [4, 31].
§Errors
Returns CryptoError::BadInput if cost < 4 or cost > 31.
Trait Implementations§
Source§impl Clone for BcryptParams
impl Clone for BcryptParams
Source§fn clone(&self) -> BcryptParams
fn clone(&self) -> BcryptParams
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for BcryptParams
impl Debug for BcryptParams
Source§impl PasswordHashParams for BcryptParams
impl PasswordHashParams for BcryptParams
Source§fn memory_cost(&self) -> Option<u32>
fn memory_cost(&self) -> Option<u32>
Memory cost in kibibytes (Argon2, scrypt) or
None if not applicable.Source§fn time_cost(&self) -> Option<u32>
fn time_cost(&self) -> Option<u32>
Time cost (iterations for PBKDF2/Argon2) or
None if not applicable.Source§fn parallelism(&self) -> Option<u32>
fn parallelism(&self) -> Option<u32>
Degree of parallelism (Argon2/scrypt) or
None if not applicable.Auto Trait Implementations§
impl Freeze for BcryptParams
impl RefUnwindSafe for BcryptParams
impl Send for BcryptParams
impl Sync for BcryptParams
impl Unpin for BcryptParams
impl UnsafeUnpin for BcryptParams
impl UnwindSafe for BcryptParams
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