Module pwhash::sha512_crypt [] [src]

SHA-512 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::sha512_crypt;

let h =
    "$6$G/gkPn17kHYo0gTF$xhDFU0QYExdMH2ghOWKrrVtu1BuTpNMSJ\
     URCXk43.EYekmK8iwV6RNqftUUC8mqDel1J7m3JEbUkbu4YyqSyv/";
assert_eq!(sha512_crypt::hash_with(h, "test").unwrap(), h);

Parameters

Hash Format

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

The format $6${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

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

hash_with

Hash a password with user-provided parameters.

verify

Verify that the hash corresponds to a password.