pub struct PasswordHash {
pub algorithm: Ident,
pub version: Option<u32>,
pub params: ParamsString,
pub salt: Option<Salt>,
pub hash: Option<Output>,
}Expand description
Password hash.
This type corresponds to the parsed representation of a PHC string as described in the PHC string format specification.
PHC strings have the following format:
$<id>[$v=<version>][$<param>=<value>(,<param>=<value>)*][$<salt>[$<hash>]]where:
<id>is the symbolic name for the function<version>is the algorithm version<param>is a parameter name<value>is a parameter value<salt>is an encoding of the salt<hash>is an encoding of the hash output
The string is then the concatenation, in that order, of:
- a
$sign; - the function symbolic name;
- optionally, a
$sign followed by the algorithm version with av=versionformat; - optionally, a
$sign followed by one or several parameters, each with aname=valueformat; the parameters are separated by commas; - optionally, a
$sign followed by the (encoded) salt value; - optionally, a
$sign followed by the (encoded) hash output (the hash output may be present only if the salt is present).
Fields§
§algorithm: IdentPassword hashing algorithm identifier.
This corresponds to the <id> field in a PHC string, a.k.a. the
symbolic name for the function.
version: Option<u32>Optional version field.
This corresponds to the <version> field in a PHC string.
params: ParamsStringAlgorithm-specific parameters.
This corresponds to the set of $<param>=<value>(,<param>=<value>)*
name/value pairs in a PHC string.
salt: Option<Salt>Salt string for personalizing a password hash output.
This corresponds to the <salt> value in a PHC string.
hash: Option<Output>Password hashing function Output, a.k.a. hash/digest.
This corresponds to the <hash> output in a PHC string.
Implementations§
Source§impl PasswordHash
impl PasswordHash
Sourcepub fn new(s: &str) -> Result<PasswordHash, Error>
pub fn new(s: &str) -> Result<PasswordHash, Error>
Parse a password hash from a string in the PHC string format.
Sourcepub fn serialize(&self) -> PasswordHashString
👎Deprecated since 0.3.0: Use PasswordHash or String instead
pub fn serialize(&self) -> PasswordHashString
Use PasswordHash or String instead
DEPRECATED: serialize this PasswordHash as a PasswordHashString.
Trait Implementations§
Source§impl Clone for PasswordHash
impl Clone for PasswordHash
Source§fn clone(&self) -> PasswordHash
fn clone(&self) -> PasswordHash
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl CustomizedPasswordHasher<PasswordHash> for Argon2<'_>
Available on crate features alloc and password-hash only.
impl CustomizedPasswordHasher<PasswordHash> for Argon2<'_>
alloc and password-hash only.Source§fn hash_password_customized(
&self,
password: &[u8],
salt: &[u8],
alg_id: Option<&str>,
version: Option<u32>,
params: Params,
) -> Result<PasswordHash>
fn hash_password_customized( &self, password: &[u8], salt: &[u8], alg_id: Option<&str>, version: Option<u32>, params: Params, ) -> Result<PasswordHash>
Source§impl Debug for PasswordHash
impl Debug for PasswordHash
Source§impl Display for PasswordHash
impl Display for PasswordHash
Source§impl FromStr for PasswordHash
impl FromStr for PasswordHash
Source§impl PartialEq for PasswordHash
impl PartialEq for PasswordHash
Source§fn eq(&self, other: &PasswordHash) -> bool
fn eq(&self, other: &PasswordHash) -> bool
self and other values to be equal, and is used by ==.Source§impl PasswordHasher<PasswordHash> for Argon2<'_>
Available on crate features alloc and password-hash only.
impl PasswordHasher<PasswordHash> for Argon2<'_>
alloc and password-hash only.Source§fn hash_password_with_salt(
&self,
password: &[u8],
salt: &[u8],
) -> Result<PasswordHash>
fn hash_password_with_salt( &self, password: &[u8], salt: &[u8], ) -> Result<PasswordHash>
H from the given password and salt, potentially using configuration
stored in &self for the parameters, or otherwise the recommended defaults. Read moreSource§impl<T> PasswordVerifier<PasswordHash> for Twhere
T: CustomizedPasswordHasher<PasswordHash>,
<T as CustomizedPasswordHasher<PasswordHash>>::Params: for<'a> TryFrom<&'a PasswordHash, Error = Error>,
Available on crate feature phc only.
impl<T> PasswordVerifier<PasswordHash> for Twhere
T: CustomizedPasswordHasher<PasswordHash>,
<T as CustomizedPasswordHasher<PasswordHash>>::Params: for<'a> TryFrom<&'a PasswordHash, Error = Error>,
phc only.Source§fn verify_password(
&self,
password: &[u8],
hash: &PasswordHash,
) -> Result<(), Error>
fn verify_password( &self, password: &[u8], hash: &PasswordHash, ) -> Result<(), Error>
Source§impl TryFrom<&PasswordHash> for Params
Available on crate feature password-hash only.
impl TryFrom<&PasswordHash> for Params
password-hash only.