```rust use argon2::{Argon2, PasswordHasher, PasswordVerifier, password_hash::Salt}; let password = "password"; // This is the b64 hash of "bad salt!" for demo only: don't do this! Instead use: // let salt = SaltString::generate(&mut OsRng); let salt_str = "YmFkIHNhbHQh"; let salt: Salt = salt_str.try_into().unwrap(); let argon2 = Argon2::default(); let hash = argon2.hash_password(password.as_bytes(), salt).unwrap(); // This is the hash we will store. Notice our salt string is included, as well as parameters: // version 0x13 (19), memory 19456KiB (19 MiB), 2 iterations (time), parallelism 1 let expected = "$argon2id$v=19$m=19456,t=2,p=1$YmFkIHNhbHQh$DqHGwv6NQV0VcaJi7jeF1E8IpfMXmXcpq4r2kKyqpXk"; // ^ hash ^ parameters ^ salt ^ combined hash assert_eq!(expected, hash.to_string()); // The verifier reads the salt and the parameters from the hash and verifies the result is equal Argon2::default().verify_password(password.as_bytes(), &hash).expect("invalid password"); ```