Skip to content

Commit 7acf5cc

Browse files
committed
adding test case
1 parent 40c2415 commit 7acf5cc

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/password_hashers/argon2.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,18 @@ pub extern "C" fn argon2_hash_password_parameters(memory_cost: u32, iterations:
1919
return hash_cstr;
2020
}
2121

22+
#[test]
23+
fn argon2_hash_password_parameters_test() {
24+
let password = "TestPassword123!";
25+
let password_cstr = CString::new(password).unwrap();
26+
let password_bytes = password_cstr.as_bytes_with_nul();
27+
28+
let hash = argon2_hash_password_parameters(1024, 2, 1, password_bytes.as_ptr() as *const i8);
29+
let hash_cstr = unsafe { CString::from_raw(hash) };
30+
let hash_str = hash_cstr.to_str().unwrap();
31+
assert!(!hash_str.is_empty());
32+
assert_ne!(hash_str, password);
33+
}
2234

2335
#[no_mangle]
2436
pub extern "C" fn argon2_derive_aes_128_key(hashed_password: *const c_char) -> Argon2KDFAes128 {

0 commit comments

Comments
 (0)