BCrypter
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:
[]
= "0.1.1"
Usage
Basic hash
extern crate bcrypter;
use password;
let pw = "hunter2".to_string;
let result = password.hash.unwrap;
let bcrypt_hash_string = result.hash_string;
Custom cost
let result = password
.cost
.hash
.unwrap;
Custom salt
let salt = ;
let result = password
.salt
.cost
.hash
.unwrap;
Verify password
let known_hash = "$2a$04$7eAf8viXin8zazyvaU2HLuZGEbvaHy/lsnlG.HFWkBST5irHhXKJO".to_string;
let correct_password : bool = password
.verify
.unwrap
Raw digest
let result = password.hash.unwrap;
let digest_bytes : = result.digest;
Notes
-
The default cost is 12
-
A random 16 byte array is used when no salt parameter is provided.
-
The maximum password input is 72 bytes, anything over that will be truncated rather than raise an error. If you need larger inputs consider hashing it beforehand.