1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//! Utilities for generating cryptographically secure salts for password hashing.
//!
//! This module provides a function to generate a random salt suitable for use with Argon2 password hashing.
//! It uses the operating system's cryptographically secure random number generator to ensure high entropy.
//!
//! # Example
//!
//! ```rust
//! use authen::core::hash::salt::generate_secure_salt;
//!
//! let salt = generate_secure_salt().expect("Failed to generate salt");
//! println!("Salt: {}", salt.as_str());
//! ```
use ;
use ;
/// Generates a cryptographically secure random salt for password hashing.
///
/// This function uses the operating system's secure random number generator to fill a 16-byte array,
/// then encodes it as a base64 salt string compatible with Argon2 password hashing.
///
/// # Errors
///
/// Returns a [`PasswordHashError`] if the random number generator fails or if the salt encoding fails.
///
/// # Example
///
/// ```rust
/// use authen::core::hash::salt::generate_secure_salt;
/// let salt = generate_secure_salt().expect("Failed to generate salt");
/// println!("Salt: {}", salt.as_str());
/// ```