Rust

argon2

Module

The Argon2id password hash.

Contents

use utopia_auth::hashes::argon2::Argon2;
Rust
pub struct Argon2

The Argon2id password hash, in the standard $argon2id$ format.

Options: type, memory_cost (KiB), time_cost and threads.

Rust
use utopia_auth::Hash;
use utopia_auth::hashes::Argon2;

let mut argon2 = Argon2::new();
argon2.set_memory_cost(7168).set_time_cost(5).set_threads(1);
let hash = argon2.hash(b"secret")?;
assert!(hash.starts_with(b"$argon2id$v=19$m=7168,t=5,p=1$"));
assert!(argon2.verify(b"secret", &hash)?);
Also implements Default.