Expand description
libpwquality bindings for Rust
§Example
use libpwquality::{PWQError, PWQuality};
fn main() -> Result<(), PWQError> {
let pwq = PWQuality::new()?;
pwq.read_default_config()?
.min_length(9)
.max_repeat(2)
.bad_words(["bad", "password"])?;
let password = pwq.generate(32)?;
println!("password={:?}", password);
let score = pwq.check(&password, None, None)?;
println!("score={}", score);
Ok(())
}
§Cargo features
-
vX_Y_Z
: Build with system libpwquality version X.Y.Z. -
vendored
: Build with vendored libpwquality. This requires cracklib to be installed. You can also setCRACKLIB_INCLUDE_PATH
andCRACKLIB_LIBRARY_PATH
environment variables to specify the include path and library path. -
vendored-cracklib
: Build with vendored libpwquality and cracklib. The build script will try to guess the path of cracklib dictionaries, but you can setDEFAULT_CRACKLIB_DICT
environment variable to override it.
Structs§
PWQuality
Error.PWQuality
instance that holds the underlying pwquality_settings_t.