Crates.io | pwhash |
lib.rs | pwhash |
version | 1.0.0 |
source | src |
created_at | 2016-02-09 22:39:09.598445 |
updated_at | 2021-01-03 18:20:47.082322 |
description | A collection of password hashing routines in pure Rust. |
homepage | https://github.com/inejge/pwhash |
repository | https://github.com/inejge/pwhash |
max_upload_size | |
id | 4140 |
size | 108,213 |
A collection of password hashing and verification routines.
See the documentation for API reference.
Add the following to the [dependencies]
section of your Cargo.toml
:
pwhash = "1"
use pwhash::bcrypt;
// Hash a password with default parameters.
let h_new = bcrypt::hash("password").unwrap();
// Verify a password against an existing hash.
let h = "$2y$05$bvIG6Nmid91Mu9RcmmWZfO\
5HJIMCT8riNW0hEp8f6/FuA2/mHZFpe";
assert!(bcrypt::verify("password", h));
The following algorithms are currently implemented (in alphabetical order):
bcrypt
bsdi_crypt
md5_crypt
sha1_crypt
sha256_crypt
sha512_crypt
unix_crypt
Each algorithm resides in its eponymous module, and provides the following interface:
verify()
: verify a password against a hash.
hash()
: hash a password with default algorithm-spacific parameters.
hash_with()
: hash a password with customized parameters.
There is also a convenience module unix
which provides the functions
unix::crypt
, a crypt(3) work-alike, and unix::verify
.