Module pwhash::sha256_crypt [] [src]

SHA-256 based hash.

This algorithm was developed as an alternative to bcrypt with NIST-approved hashing functions. It is similar to MD5-crypt, but has a variable number of rounds and a larger salt.

Example

use pwhash::sha256_crypt;

let h = "$5$rounds=11858$WH1ABM5sKhxbkgCK$\
         aTQsjPkz0rBsH3lQlJxw9HDTDXPKBxC0LlVeV69P.t1";
assert_eq!(sha256_crypt::hash_with(h, "test").unwrap(), h);

Parameters

Hash Format

The format of the hash is $5$rounds={rounds}${salt}${checksum}, where:

The format $5${salt}${checksum} can be used if the default number of rounds is chosen.

Constants

DEFAULT_ROUNDS

Default number of rounds.

MAX_ROUNDS

Maximum rounds.

MAX_SALT_LEN

Maximum (and default) salt length.

MIN_ROUNDS

Minimum rounds.

Functions

hash [
Deprecated
]

Hash a password with a randomly generated salt and the default number of rounds.

hash_with [
Deprecated
]

Hash a password with user-provided parameters.

verify

Verify that the hash corresponds to a password.