pub struct BCryptPasswordEncoder { /* private fields */ }Expand description
BCrypt password encoder - widely compatible with other frameworks.
§Spring Security Equivalent
BCryptPasswordEncoder
BCrypt is a widely-used password hashing algorithm that is compatible with many other frameworks (PHP, Node.js, etc.). Use this when migrating from other systems or for interoperability.
§Feature Flag
Requires the bcrypt feature.
§Example
ⓘ
use actix_security_core::http::security::crypto::{PasswordEncoder, BCryptPasswordEncoder};
let encoder = BCryptPasswordEncoder::new();
let hash = encoder.encode("secret_password");
// Verify correct password
assert!(encoder.matches("secret_password", &hash));Implementations§
Source§impl BCryptPasswordEncoder
impl BCryptPasswordEncoder
Sourcepub fn new() -> BCryptPasswordEncoder
pub fn new() -> BCryptPasswordEncoder
Creates a new BCrypt password encoder with default cost (12).
Sourcepub fn with_cost(cost: u32) -> BCryptPasswordEncoder
pub fn with_cost(cost: u32) -> BCryptPasswordEncoder
Creates a new BCrypt password encoder with custom cost.
Cost should be between 4 and 31. Higher values are more secure but slower. Default is 12.
Sourcepub fn with_strength(strength: &str) -> BCryptPasswordEncoder
pub fn with_strength(strength: &str) -> BCryptPasswordEncoder
Create encoder with strength level.
weak: cost 10 (fast, for development)default: cost 12 (balanced)strong: cost 14 (secure, slower)
Trait Implementations§
Source§impl Clone for BCryptPasswordEncoder
impl Clone for BCryptPasswordEncoder
Source§fn clone(&self) -> BCryptPasswordEncoder
fn clone(&self) -> BCryptPasswordEncoder
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Default for BCryptPasswordEncoder
Available on crate feature bcrypt only.
impl Default for BCryptPasswordEncoder
Available on crate feature
bcrypt only.Source§fn default() -> BCryptPasswordEncoder
fn default() -> BCryptPasswordEncoder
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for BCryptPasswordEncoder
impl RefUnwindSafe for BCryptPasswordEncoder
impl Send for BCryptPasswordEncoder
impl Sync for BCryptPasswordEncoder
impl Unpin for BCryptPasswordEncoder
impl UnwindSafe for BCryptPasswordEncoder
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> 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>
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