Struct password_hash::PasswordHash[][src]

pub struct PasswordHash<'a> {
    pub algorithm: Ident<'a>,
    pub version: Option<Decimal>,
    pub params: ParamsString,
    pub salt: Option<Salt<'a>>,
    pub hash: Option<Output>,
}

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>[$<param>=<value>(,<param>=<value>)*][$<salt>[$<hash>]]

where:

  • <id> is the symbolic name for the function
  • <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 one or several parameters, each with a name=value format; 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: Ident<'a>

Password hashing algorithm identifier.

This corresponds to the <id> field in a PHC string, a.k.a. the symbolic name for the function.

version: Option<Decimal>

Optional version field.

An augmented form of the PHC string format used by Argon2 includes an additional version field out-of-band from other parameters:

$<id>[$v=<version>][$<param>=<value>(,<param>=<value>)*][$<salt>[$<hash>]]

See: https://github.com/P-H-C/phc-string-format/pull/4

params: ParamsString

Algorithm-specific parameters.

This corresponds to the set of $<param>=<value>(,<param>=<value>)* name/value pairs in a PHC string.

salt: Option<Salt<'a>>

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

impl<'a> PasswordHash<'a>[src]

pub fn new(s: &'a str) -> Result<Self, HashError>[src]

Parse a password hash from a string in the PHC string format.

pub fn parse(s: &'a str, encoding: Encoding) -> Result<Self, HashError>[src]

Parse a password hash from the given Encoding.

pub fn generate(
    phf: impl PasswordHasher,
    password: impl AsRef<[u8]>,
    salt: &'a str
) -> Result<Self, HasherError>
[src]

Generate a password hash using the supplied algorithm.

pub fn verify_password(
    &self,
    phfs: &[&dyn PasswordVerifier],
    password: impl AsRef<[u8]>
) -> Result<(), VerifyError>
[src]

Verify this password hash using the specified set of supported PasswordHasher trait objects.

pub fn encoding(&self) -> Encoding[src]

Get the Encoding that this PasswordHash is serialized with.

Trait Implementations

impl<'a> Clone for PasswordHash<'a>[src]

impl<'a> Debug for PasswordHash<'a>[src]

impl<'a> Display for PasswordHash<'a>[src]

impl<'a> Eq for PasswordHash<'a>[src]

impl<'a> PartialEq<PasswordHash<'a>> for PasswordHash<'a>[src]

impl<'a> StructuralEq for PasswordHash<'a>[src]

impl<'a> StructuralPartialEq for PasswordHash<'a>[src]

impl<'a> TryFrom<&'a str> for PasswordHash<'a>[src]

type Error = HashError

The type returned in the event of a conversion error.

Auto Trait Implementations

impl<'a> Send for PasswordHash<'a>[src]

impl<'a> Sync for PasswordHash<'a>[src]

impl<'a> Unpin for PasswordHash<'a>[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.