A collection of password hashing routines in pure Rust
Clone or download
Latest commit 114396f Jan 13, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src Bump version to 0.3 Jan 13, 2019
.gitignore Initial commit Feb 9, 2016
.travis.yml Update doc generation on Travis May 9, 2018
Cargo.toml Bump version to 0.3 Jan 13, 2019
LICENSE-MIT Rename LICENSE Apr 1, 2017
README.md Bump version to 0.3 Jan 13, 2019

README.md

pwhash

Build Status

A collection of password hashing and verification routines.

See the documentation for API reference.

Getting Started

Add the following to the [dependencies] section of your Cargo.toml:

pwhash = "0.3"

Also, import the crate in your crate root:

extern crate pwhash;

Example

extern crate pwhash;

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));

Summary

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.