BCrypter

Crates.io Build Status Crates.io

A pure rust implementation of the bcrypt hashing function based on the Blowfish cipher. Currently only running on nightly builds. Full API documentation can be found here

Installation

In your Cargo.toml file:

toml [dependencies] bcrypter = "0.1.1"

Usage

Basic hash

```rust extern crate bcrypter; use bcrypter::password;

let pw = "hunter2".tostring(); let result = password(pw).hash().unwrap(); let bcrypthashstring = result.hashstring; ```

Custom cost

rust let result = password(pw) .cost(6) .hash() .unwrap();

Custom salt

rust let salt = [0u8; 16]; let result = password(pw) .salt(salt) .cost(8) .hash() .unwrap();

Verify password

rust let known_hash = "$2a$04$7eAf8viXin8zazyvaU2HLuZGEbvaHy/lsnlG.HFWkBST5irHhXKJO".to_string(); let correct_password : bool = password(pw) .verify(known_hash) .unwrap()

Raw digest

rust let result = password(pw).hash().unwrap(); let digest_bytes : [u8: 24] = result.digest;

Notes