#password #hash #hashing #crypt

pwhash

A collection of password hashing routines in pure Rust

4 releases (2 breaking)

0.3.0 Jan 13, 2019
0.2.0 May 9, 2018
0.1.2 Apr 1, 2017
0.1.1 Feb 9, 2016

#144 in Cryptography

Download history 92/week @ 2019-03-25 44/week @ 2019-04-01 24/week @ 2019-04-08 30/week @ 2019-04-15 34/week @ 2019-04-22 41/week @ 2019-04-29 38/week @ 2019-05-06 82/week @ 2019-05-13 80/week @ 2019-05-20 75/week @ 2019-05-27 61/week @ 2019-06-03 76/week @ 2019-06-10 55/week @ 2019-06-17 47/week @ 2019-06-24 117/week @ 2019-07-01

276 downloads per month
Used in 6 crates

MIT license

105KB
1.5K SLoC

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.

Dependencies

~1.5MB
~19K SLoC