dls: add password hash function
This commit is contained in:
17
src/dls/store.rs
Normal file
17
src/dls/store.rs
Normal 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()) }
|
||||
}
|
||||
Reference in New Issue
Block a user