pub struct Argon2Hasher { /* private fields */ }Expand description
Configurable Argon2id hasher.
Implementations§
Source§impl Argon2Hasher
impl Argon2Hasher
Sourcepub fn new_recommended() -> Result<Self>
pub fn new_recommended() -> Result<Self>
Creates a new instance with recommended settings based on the current build (dev/release).
Sourcepub fn from_config(config: Argon2Config) -> Result<Self>
pub fn from_config(config: Argon2Config) -> Result<Self>
Create from explicit configuration.
Sourcepub fn from_preset(preset: Argon2Preset) -> Result<Self>
pub fn from_preset(preset: Argon2Preset) -> Result<Self>
Create from a preset.
Sourcepub fn config(&self) -> &Argon2Config
pub fn config(&self) -> &Argon2Config
Return current configuration.
Sourcepub fn high_security() -> Result<Self>
pub fn high_security() -> Result<Self>
Maximum security hasher for production environments.
Parameters:
- Memory: 64 MiB (65,536 KiB)
- Time cost: 3 iterations
- Parallelism: 1 thread
Use cases:
- Production servers with sufficient memory
- High-value accounts requiring maximum security
- Applications where authentication latency is acceptable (~100-200ms)
Security: Provides excellent protection against brute-force attacks and rainbow tables, suitable for protecting sensitive user credentials.
Performance: Slowest option, designed for security over speed.
Sourcepub fn interactive() -> Result<Self>
pub fn interactive() -> Result<Self>
Balanced hasher for interactive applications.
Parameters:
- Memory: 32 MiB (32,768 KiB)
- Time cost: 2 iterations
- Parallelism: 1 thread
Use cases:
- Web applications with user-facing login forms
- Mobile applications where response time matters
- Services with moderate security requirements
- Memory-constrained production environments
Security: Good security level, still resistant to most attacks while providing reasonable authentication response times.
Performance: Moderate speed (~50-100ms), good balance of security and usability.
Sourcepub fn dev_fast() -> Result<Self>
pub fn dev_fast() -> Result<Self>
Fast hasher for development and testing only.
⚠️ WARNING: DO NOT USE IN PRODUCTION
Parameters:
- Memory: 4 MiB (4,096 KiB)
- Time cost: 1 iteration
- Parallelism: 1 thread
Use cases:
- Local development to speed up test cycles
- Unit tests that need fast password hashing
- CI/CD pipelines to reduce build times
- Debug builds (automatically used by
default())
Security: ⚠️ Insufficient for production use - vulnerable to brute-force attacks
Performance: Very fast (~5-20ms), prioritizes development speed over security.
This preset is only available in debug builds or when the insecure-fast-hash
feature is explicitly enabled.
Trait Implementations§
Source§impl Clone for Argon2Hasher
impl Clone for Argon2Hasher
Source§fn clone(&self) -> Argon2Hasher
fn clone(&self) -> Argon2Hasher
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl HashingService for Argon2Hasher
impl HashingService for Argon2Hasher
Source§fn hash_value(&self, plain_value: &str) -> Result<HashedValue>
fn hash_value(&self, plain_value: &str) -> Result<HashedValue>
Source§fn verify_value(
&self,
plain_value: &str,
hashed_value: &str,
) -> Result<VerificationResult>
fn verify_value( &self, plain_value: &str, hashed_value: &str, ) -> Result<VerificationResult>
Auto Trait Implementations§
impl Freeze for Argon2Hasher
impl RefUnwindSafe for Argon2Hasher
impl Send for Argon2Hasher
impl Sync for Argon2Hasher
impl Unpin for Argon2Hasher
impl UnwindSafe for Argon2Hasher
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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>
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