Expand description
§RustCrypto: SHA-crypt password hash
Pure Rust implementation of the SHA-crypt password hash based on SHA-256/SHA-512, a legacy password hashing scheme supported by the POSIX crypt C library.
Password hashes using this algorithm start with $5$ or $6$ when encoded
using the Modular Crypt Format.
§License
Licensed under either of:
at your option.
§Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
§Usage
// NOTE: example requires `getrandom` feature is enabled
use sha_crypt::{PasswordHasher, PasswordVerifier, ShaCrypt};
let sha_crypt = ShaCrypt::default(); // default is SHA-512-crypt
let password = b"pleaseletmein"; // don't actually use this as a password!
let password_hash = sha_crypt.hash_password(password)?;
assert!(password_hash.as_str().starts_with("$6$"));
// verify password is correct for the given hash
sha_crypt.verify_password(password, &password_hash)?;Re-exports§
pub use password_hash;password-hash
Structs§
- Params
- Algorithm parameters.
- Password
Hash password-hash - Password hash encoded in the Modular Crypt Format (MCF). Owned form with builder functionality.
- Password
Hash Ref password-hash - Password hash reference type for hashes encoded in the Modular Crypt Format (MCF),
e.g.
$<id>$.... - ShaCrypt
password-hash - SHA-crypt type for use with the
PasswordHasherandPasswordVerifiertraits, which can produce and verify password hashes inModular Crypt Format.
Enums§
Constants§
- BLOCK_
SIZE_ SHA256 - Block size for SHA-256-crypt.
- BLOCK_
SIZE_ SHA512 - Block size for SHA-512-crypt.
Traits§
- Customized
Password Hasher password-hash - Trait for password hashing functions which support customization.
- Password
Hasher password-hash - High-level trait for password hashing functions.
- Password
Verifier password-hash - Trait for password verification.
Functions§
- sha256_
crypt - The SHA-256-crypt function which outputs a uniformly random byte array.
- sha512_
crypt - The SHA-512-crypt function which outputs a uniformly random byte array.