3 releases (breaking)

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

#369 in Authentication

Download history 4/week @ 2024-11-13 7/week @ 2024-11-20 2/week @ 2024-11-27 7/week @ 2024-12-04 12/week @ 2024-12-11 20/week @ 2024-12-18 38/week @ 2024-12-25 60/week @ 2025-01-01 140/week @ 2025-01-08 394/week @ 2025-01-15 166/week @ 2025-01-22 28/week @ 2025-02-05

618 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