dls: add password hash function

This commit is contained in:
Mikaël Cluseau
2026-03-16 11:06:19 +01:00
parent 4b1edb2a55
commit 4619899e65
6 changed files with 216 additions and 647 deletions

17
src/dls/store.rs Normal file
View File

@@ -0,0 +1,17 @@
pub fn hash_password(salt: &[u8], passphrase: &str) -> argon2::Result<[u8; 32]> {
let hash = argon2::hash_raw(
passphrase.as_bytes(),
salt,
&argon2::Config {
variant: argon2::Variant::Argon2id,
hash_length: 32,
time_cost: 1,
mem_cost: 65536,
thread_mode: argon2::ThreadMode::Parallel,
lanes: 4,
..Default::default()
},
)?;
unsafe { Ok(hash.try_into().unwrap_unchecked()) }
}