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
-
Password length: unlimited.
-
Salt length: 0 to 16 characters. Default is 16.
-
Rounds: 1000 to 999999999. Default is 5000. If a number outside of the range is chosen, it is coerced to the nearest limit.
Hash Format
The format of the hash is
$6$rounds=
{rounds}
${salt}
${checksum}
, where:
-
{rounds}
is the number of rounds, encoded as a decimal number without leading zeroes. -
{salt}
is the salt string. -
{checksum}
is a 86-character Base64 encoding of the checksum.
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. |