14 unstable releases (5 breaking)
| 0.6.2 | Oct 17, 2024 |
|---|---|
| 0.6.0 | Sep 29, 2024 |
| 0.3.0 | Jul 23, 2023 |
| 0.1.0 | Mar 29, 2023 |
#689 in Build Utils
1,263 downloads per month
Used in libpwquality
120KB
3.5K
SLoC
libpwquality bindings for Rust
Usage
cargo add libpwquality
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 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(())
}
Cargo features
-
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 setCRACKLIB_INCLUDE_PATHandCRACKLIB_LIBRARY_PATHenvironment 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 setDEFAULT_CRACKLIB_DICTenvironment variable to override it. Disabled by default.
Dependencies
~0–2.1MB
~42K SLoC