From 576d0cbf4457c3e8746d29715040ac3bb2101459 Mon Sep 17 00:00:00 2001 From: Mike Mulchrone Date: Sat, 10 Jan 2026 13:13:12 -0500 Subject: [PATCH 1/2] bcrypt parameters --- Cargo.toml | 2 +- src/password_hashers/bcrypt.rs | 9 +++++++++ tests/password_hashers.rs | 8 +++++++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 1a9e2b4..0d46f94 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cas-lib" -version = "0.2.69" +version = "0.2.70" edition = "2021" description = "A function wrapper layer for RustCrypto and Dalek-Cryptography. Intended to be used in FFI situations with a global heap deallactor at the top level project." license = "Apache-2.0" diff --git a/src/password_hashers/bcrypt.rs b/src/password_hashers/bcrypt.rs index 921b6d8..fd17129 100644 --- a/src/password_hashers/bcrypt.rs +++ b/src/password_hashers/bcrypt.rs @@ -5,6 +5,15 @@ use bcrypt::{hash, verify, DEFAULT_COST}; pub struct CASBCrypt; impl CASBCrypt { + /// Hashes a password using bcrypt with a customized cost. + /// Parameters: + /// - password_to_hash: The password to be hashed. + /// - cost: The cost parameter for bcrypt (default is 12 and max is 31). + /// Returns the hashed password as a string. + pub fn hash_password_customized(password_to_hash: String, cost: u32) -> String { + return hash(password_to_hash, cost).unwrap(); + } + /// Hashes a password using bcrypt. /// Returns the hashed password as a string. pub fn hash_password(password_to_hash: String) -> String { diff --git a/tests/password_hashers.rs b/tests/password_hashers.rs index aea8032..4520552 100644 --- a/tests/password_hashers.rs +++ b/tests/password_hashers.rs @@ -69,5 +69,11 @@ mod password_hashers { assert_eq!(true, verification); } - + #[test] + pub fn bcrypt_hash_password_customized() { + let password = "DoNotUseThisPassword".to_string(); + let hash = CASBCrypt::hash_password_customized(password.clone(), 12); + let verification = CASBCrypt::verify_password(hash, password); + assert_eq!(true, verification); + } } \ No newline at end of file From 24b0dd550e933d5f59d947594624b3fc9865e75f Mon Sep 17 00:00:00 2001 From: Mike Mulchrone Date: Sat, 10 Jan 2026 13:14:10 -0500 Subject: [PATCH 2/2] change name of action --- .github/workflows/publish-main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-main.yml b/.github/workflows/publish-main.yml index 4b39bfb..414947d 100644 --- a/.github/workflows/publish-main.yml +++ b/.github/workflows/publish-main.yml @@ -16,5 +16,5 @@ jobs: - uses: actions/checkout@v4 - name: Build run: cargo build --release --verbose - - name: Run tests + - name: Publish run: cargo publish --token ${{ secrets.TOKEN }}