#native-bindings #dictionary #path #pwquality #libpwquality #cracklib

sys libpwquality-sys

Native bindings to the libpwquality library

4 releases (2 breaking)

0.3.0 Jul 23, 2023
0.2.1 May 11, 2023
0.2.0 Apr 1, 2023
0.1.0 Mar 29, 2023

#96 in #native-bindings

Download history 8/week @ 2024-01-01 24/week @ 2024-01-08 24/week @ 2024-01-15 22/week @ 2024-01-22 43/week @ 2024-02-05 45/week @ 2024-02-12 54/week @ 2024-02-19 27/week @ 2024-02-26 92/week @ 2024-03-11 280/week @ 2024-04-01

372 downloads per month
Used in libpwquality

MIT license

270KB
4.5K SLoC

C 4K SLoC // 0.1% comments Python 243 SLoC // 0.2% comments Rust 191 SLoC Automake 137 SLoC // 0.1% comments Shell 7 SLoC // 0.6% comments Forge Config 5 SLoC

Contains (obscure autoconf code, 7KB) libpwquality/configure.ac, (obscure autoconf code, 4KB) cracklib/src/configure.ac

libpwquality bindings for Rust

Crates.io Crates.io License docs.rs Build Status

Usage

cargo add libpwquality

libpwquality-rs links system libpwquality library by default, you can optionally enable vendored feature and install cracklib dictionaries to build libpwquality. When the vendored feature is enabled, you can export DEFAULT_CRACKLIB_DICT environment variable to specify the path of the dictionaries if you encounter problems with the dictionary path.

cargo add libpwquality --features vendored
sudo apt-get install cracklib-runtime

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(())
}

lib.rs:

Native bindings to the libpwquality library

Dependencies