3 releases (breaking)

0.3.0 Oct 10, 2024
0.2.0 Oct 10, 2024
0.1.0 Oct 9, 2024

#381 in Authentication

Download history 281/week @ 2024-10-04 157/week @ 2024-10-11 7/week @ 2024-10-18 7/week @ 2024-11-15 5/week @ 2024-11-22 4/week @ 2024-11-29 8/week @ 2024-12-06 21/week @ 2024-12-13 9/week @ 2024-12-20 53/week @ 2024-12-27 49/week @ 2025-01-03 248/week @ 2025-01-10

364 downloads per month

MIT license

11KB
137 lines

libxcrypt-rs

Rust bindings for libxcrypt

Usage

Add xcrypt to your Cargo.toml:

cargo add xcrypt

Hash a phrase with the best available hashing method and default parameters:

use xcrypt::{crypt, crypt_gensalt};

fn main() {
    let setting = crypt_gensalt(None, 0, None).unwrap();
    let hashed_phrase = crypt("hello", &setting).unwrap();

    println!("{hashed_phrase}");
}

lib.rs:

Bindings for libxcrypt.

Examples

Hash a phrase with the best available hashing method and default parameters:

use xcrypt::{crypt, crypt_gensalt};

let setting = crypt_gensalt(None, 0, None).unwrap();
crypt("hello", &setting);

You can also explicitly request a specific hashing method:

use xcrypt::{crypt, crypt_gensalt};

let setting = crypt_gensalt(Some("$6$"), 0, None).unwrap();
crypt("hello", &setting);

Dependencies

~0–2MB
~38K SLoC