From b31e90ea3c99d4e526a7bbff2e41c256b48fdfd6 Mon Sep 17 00:00:00 2001 From: Sebastien Rousseau Date: Sun, 5 Nov 2023 16:49:27 +0000 Subject: [PATCH] docs(hsh): :memo: updated source code documentation --- src/algorithms/bcrypt.rs | 6 +++--- src/algorithms/scrypt.rs | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/algorithms/bcrypt.rs b/src/algorithms/bcrypt.rs index a28b5d4..fc036fd 100644 --- a/src/algorithms/bcrypt.rs +++ b/src/algorithms/bcrypt.rs @@ -35,13 +35,13 @@ pub struct Bcrypt; impl HashingAlgorithm for Bcrypt { /// Hashes a given password using the Bcrypt algorithm. /// - /// Given a plaintext `password` and a `salt`, this method returns a hashed representation - /// of the password using the Bcrypt algorithm. + /// This method computes a hashed representation of the plaintext `password` using the Bcrypt algorithm. + /// Note that the `salt` parameter is not used in this implementation, as Bcrypt generates its own salt internally. /// /// # Parameters /// /// - `password`: The plaintext password to be hashed. - /// - `salt`: A cryptographic salt to prevent rainbow table attacks. + /// - `_salt`: Unused in this implementation, provided for interface compatibility. /// /// # Returns /// diff --git a/src/algorithms/scrypt.rs b/src/algorithms/scrypt.rs index ddf6ec1..ed05837 100644 --- a/src/algorithms/scrypt.rs +++ b/src/algorithms/scrypt.rs @@ -33,6 +33,10 @@ impl HashingAlgorithm for Scrypt { /// Returns a `Result` containing the hashed password as a vector of bytes. /// If hashing fails for some reason, it returns a `String` detailing the error. fn hash_password(password: &str, salt: &str) -> Result, String> { + // The `Params` struct is initialized with specific parameters that define the + // computational cost of the hashing process. The parameters used here are chosen + // to provide a balance between security and performance. Adjust these values based + // on the security requirements and the expected computational capacity. let params = Params::new(14, 8, 1, 64).map_err(|e| e.to_string())?; let mut output = [0u8; 64]; scrypt(