Expand description
Pure Rust implementation of the SHA-crypt
password hash based on SHA-512,
a legacy password hashing scheme supported by the POSIX crypt C library.
Password hashes using this algorithm start with $6$
when encoded using the
PHC string format.
§Usage
use sha_crypt::{Sha512Params, sha512_simple, sha512_check};
// First setup the Sha512Params arguments with:
// rounds = 10_000
let params = Sha512Params::new(10_000).expect("RandomError!");
// Hash the password for storage
let hashed_password = sha512_simple("Not so secure password", ¶ms)
.expect("Should not fail");
// Verifying a stored password
assert!(sha512_check("Not so secure password", &hashed_password).is_ok());
Structs§
- Sha256
Params - Algorithm parameters.
- Sha512
Params - Algorithm parameters.
Enums§
- Crypt
Error - Error type.
Constants§
- BLOCK_
SIZE_ SHA256 - Block size for SHA256
- BLOCK_
SIZE_ SHA512 - Block size for SHA512
- ROUNDS_
DEFAULT - Default number of rounds.
- ROUNDS_
MAX - Maximum number of rounds allowed.
- ROUNDS_
MIN - Minimum number of rounds allowed.
Functions§
- sha256_
check simple
- Checks that given password matches provided hash.
- sha256_
crypt - The SHA256 crypt function returned as byte vector
- sha256_
crypt_ b64 - Same as sha256_crypt except base64 representation will be returned.
- sha256_
simple simple
- Simple interface for generating a SHA256 password hash.
- sha512_
check simple
- Checks that given password matches provided hash.
- sha512_
crypt - The SHA512 crypt function returned as byte vector
- sha512_
crypt_ b64 - Same as sha512_crypt except base64 representation will be returned.
- sha512_
simple simple
- Simple interface for generating a SHA512 password hash.