password
ModuleUser passwords: a registry of named hashes, the one in use, and random password generation.
Contents
use utopia_auth::proofs::password::Password;Rust
pub struct PasswordA user password: a registry of named hashes (every built-in by default), the one in use, and how generated passwords look (16 characters from a symbol-rich charset).
Rust
use utopia_auth::proofs::{Password, Proof};
let mut password = Password::new();
password.use_hash("bcrypt")?;
let hash = password.hash(b"secret")?;
assert!(hash.starts_with(b"$2y$"));
assert!(password.verify(b"secret", &hash)?);
// Generated passwords are 16 characters long.
assert_eq!(password.generate()?.len(), 16);Also implements
Default.use utopia_auth::proofs::password::set_options;Rust
pub fn set_options(hash: &mut dyn Hash, options: &Array) -> Result<(), Error>Sets every option in options on hash, in order.
Fails with Error::Type at the first integer key: option names are strings.
Rust
pub const ARGON2: &str = "argon2"The registered name of Argon2.
Rust
pub const BCRYPT: &str = "bcrypt"The registered name of Bcrypt.
Rust
pub const MD5: &str = "md5"The registered name of Md5.
Rust
pub const PHPASS: &str = "phpass"The registered name of the phpass hash.
Rust
pub const SCRYPT: &str = "scrypt"The registered name of Scrypt.
Rust
pub const SCRYPT_MODIFIED: &str = "scryptMod"The registered name of ScryptModified.
Rust
pub const SHA: &str = "sha"The registered name of Sha.