| Crates.io | libpwquality |
| lib.rs | libpwquality |
| version | 0.9.2 |
| created_at | 2023-03-29 10:39:57.101131+00 |
| updated_at | 2024-10-17 06:21:22.988242+00 |
| description | libpwquality bindings for Rust |
| homepage | |
| repository | https://github.com/nibon7/libpwquality-rs |
| max_upload_size | |
| id | 823987 |
| size | 46,347 |
cargo add libpwquality
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 minlen = pwq.get_min_length();
println!("minlen={}", minlen);
let badwords = pwq.get_bad_words()?;
println!("badwords={:?}", badwords);
let maxrepeat = pwq.get_max_repeat();
println!("maxrepeat={}", maxrepeat);
let password = pwq.generate(32)?;
println!("password={:?}", password);
let score = pwq.check(&password, Some("password!"), None)?;
println!("score={}", score);
Ok(())
}
vX_Y_Z: Build with system libpwquality version X.Y.Z.
v1_0 Enabled by default.
vendored: Build with vendored libpwquality.
This requires cracklib to be installed.
You can also set CRACKLIB_INCLUDE_PATH and CRACKLIB_LIBRARY_PATH
environment variables to specify the include path and library path.
Disabled by default.
vendored-cracklib: Build with vendored libpwquality and cracklib.
The build script will try to guess the path of cracklib dictionaries,
but you can set DEFAULT_CRACKLIB_DICT environment variable to override it.
Disabled by default.