pub struct CryptoUtils;Expand description
Utility functions for generating random values
Implementations§
Source§impl CryptoUtils
impl CryptoUtils
Sourcepub fn generate_random_string(length: usize) -> String
pub fn generate_random_string(length: usize) -> String
Generate a random string of specified length using alphanumeric characters
Sourcepub fn generate_token(length: usize) -> String
pub fn generate_token(length: usize) -> String
Generate a secure random token
Sourcepub fn generate_backup_codes(count: usize, length: usize) -> Vec<String>
pub fn generate_backup_codes(count: usize, length: usize) -> Vec<String>
Generate backup codes for MFA
Sourcepub fn generate_session_id() -> String
pub fn generate_session_id() -> String
Generate a cryptographically secure session ID
Sourcepub fn generate_totp_secret() -> String
pub fn generate_totp_secret() -> String
Generate a TOTP secret key
Sourcepub fn generate_jwt_secret(length: Option<usize>) -> String
pub fn generate_jwt_secret(length: Option<usize>) -> String
Generate a JWT secret key
Sourcepub fn validate_password_strength(
password: &str,
min_length: usize,
max_length: usize,
require_uppercase: bool,
require_lowercase: bool,
require_numbers: bool,
require_special: bool,
) -> AuthResult<()>
pub fn validate_password_strength( password: &str, min_length: usize, max_length: usize, require_uppercase: bool, require_lowercase: bool, require_numbers: bool, require_special: bool, ) -> AuthResult<()>
Validate password strength based on policy
Sourcepub fn hash_password(password: &str) -> AuthResult<String>
pub fn hash_password(password: &str) -> AuthResult<String>
Hash a password with default settings
Sourcepub fn verify_password(password: &str, hash: &str) -> AuthResult<bool>
pub fn verify_password(password: &str, hash: &str) -> AuthResult<bool>
Verify a password against its hash
Auto Trait Implementations§
impl Freeze for CryptoUtils
impl RefUnwindSafe for CryptoUtils
impl Send for CryptoUtils
impl Sync for CryptoUtils
impl Unpin for CryptoUtils
impl UnsafeUnpin for CryptoUtils
impl UnwindSafe for CryptoUtils
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
impl<T> ErasedDestructor for Twhere
T: 'static,
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