pub struct PasswordHash(/* private fields */);password-hash only.Expand description
Password hash encoded in the Modular Crypt Format (MCF). Owned form with builder functionality.
Password hashes in this format take the form ${id}$..., where {id} is a short numeric or
alphanumeric algorithm identifier optionally containing a -, followed by $ as a delimiter,
further followed by an algorithm-specific serialization of a password hash, typically
using a variant (often an algorithm-specific variant) of Base64. This algorithm-specific
serialization contains one or more fields ${first}[${second}]..., where each field only uses
characters in the regexp range [A-Za-z0-9./+=,\-].
Example (SHA-crypt w\ SHA-512):
$6$rounds=100000$exn6tVc2j/MZD8uG$BI1Xh8qQSK9J4m14uwy7abn.ctj/TIAzlaVCto0MQrOFIeTXsc1iwzH16XEWo/a7c7Y9eVJvufVzYAs4EsPOy0Implementations§
Source§impl PasswordHash
impl PasswordHash
Sourcepub fn new(s: impl Into<String>) -> Result<PasswordHash, Error>
pub fn new(s: impl Into<String>) -> Result<PasswordHash, Error>
Parse the given input string, returning an PasswordHash if valid.
Sourcepub fn as_password_hash_ref(&self) -> &PasswordHashRef
pub fn as_password_hash_ref(&self) -> &PasswordHashRef
Borrow the contents of this password hash as a PasswordHashRef.
Similar conversions can be performed using AsRef, Borrow, and Deref, however
this one is useful when the return type may be ambiguous and avoiding potential
inference bugs is preferable.
Sourcepub fn from_id(id: &str) -> Result<PasswordHash, Error>
pub fn from_id(id: &str) -> Result<PasswordHash, Error>
Create an PasswordHash from an identifier.
§Returns
Error if the identifier is invalid.
Allowed characters match the regex: [a-z0-9\-], where the first and last characters do NOT
contain a -.
Sourcepub fn push_base64(&mut self, field: &[u8], base64_encoding: Base64)
Available on crate feature base64 only.
pub fn push_base64(&mut self, field: &[u8], base64_encoding: Base64)
base64 only.Encode the given data as the specified variant of Base64 and push it onto the password
hash string, first adding a $ delimiter.
Sourcepub fn push_displayable<D>(&mut self, displayable: D) -> Result<(), Error>where
D: Display,
pub fn push_displayable<D>(&mut self, displayable: D) -> Result<(), Error>where
D: Display,
Push a type which impls fmt::Display, first adding a $ delimiter and ensuring the
added characters comprise a valid field.
Sourcepub fn push_field(&mut self, field: Field<'_>)
pub fn push_field(&mut self, field: Field<'_>)
Push an additional field onto the password hash string, first adding a $ delimiter.
Methods from Deref<Target = PasswordHashRef>§
Trait Implementations§
Source§impl AsRef<PasswordHashRef> for PasswordHash
impl AsRef<PasswordHashRef> for PasswordHash
Source§fn as_ref(&self) -> &PasswordHashRef
fn as_ref(&self) -> &PasswordHashRef
Source§impl AsRef<str> for PasswordHash
impl AsRef<str> for PasswordHash
Source§impl Borrow<PasswordHashRef> for PasswordHash
impl Borrow<PasswordHashRef> for PasswordHash
Source§fn borrow(&self) -> &PasswordHashRef
fn borrow(&self) -> &PasswordHashRef
Source§impl Clone for PasswordHash
impl Clone for PasswordHash
Source§fn clone(&self) -> PasswordHash
fn clone(&self) -> PasswordHash
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl CustomizedPasswordHasher<PasswordHash> for Yescrypt
impl CustomizedPasswordHasher<PasswordHash> for Yescrypt
Source§fn hash_password_customized(
&self,
password: &[u8],
salt: &[u8],
alg_id: Option<&str>,
version: Option<Version>,
params: Params,
) -> Result<PasswordHash>
fn hash_password_customized( &self, password: &[u8], salt: &[u8], alg_id: Option<&str>, version: Option<Version>, params: Params, ) -> Result<PasswordHash>
PasswordHash] from the provided password using an
explicit set of customized algorithm parameters as opposed to the
defaults. Read moreSource§impl Debug for PasswordHash
impl Debug for PasswordHash
Source§impl Deref for PasswordHash
impl Deref for PasswordHash
Source§type Target = PasswordHashRef
type Target = PasswordHashRef
Source§fn deref(&self) -> &PasswordHashRef
fn deref(&self) -> &PasswordHashRef
Source§impl Display for PasswordHash
impl Display for PasswordHash
Source§impl<'a> From<&'a PasswordHash> for &'a PasswordHashRef
impl<'a> From<&'a PasswordHash> for &'a PasswordHashRef
Source§fn from(hash: &'a PasswordHash) -> &'a PasswordHashRef
fn from(hash: &'a PasswordHash) -> &'a PasswordHashRef
Source§impl From<&PasswordHashRef> for PasswordHash
impl From<&PasswordHashRef> for PasswordHash
Source§fn from(hash: &PasswordHashRef) -> PasswordHash
fn from(hash: &PasswordHashRef) -> PasswordHash
Source§impl FromStr for PasswordHash
impl FromStr for PasswordHash
Source§impl Ord for PasswordHash
impl Ord for PasswordHash
Source§fn cmp(&self, other: &PasswordHash) -> Ordering
fn cmp(&self, other: &PasswordHash) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for PasswordHash
impl PartialEq for PasswordHash
Source§impl PartialOrd for PasswordHash
impl PartialOrd for PasswordHash
Source§impl PasswordHasher<PasswordHash> for Yescrypt
impl PasswordHasher<PasswordHash> for Yescrypt
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§fn hash_password(&self, password: &[u8]) -> Result<H, Error>
fn hash_password(&self, password: &[u8]) -> Result<H, Error>
getrandom only.H from the given password, potentially using configuration stored in
&self for the parameters, or otherwise the recommended defaults. Read moreSource§fn hash_password_with_rng<R>(
&self,
rng: &mut R,
password: &[u8],
) -> Result<H, Error>where
R: TryCryptoRng + ?Sized,
fn hash_password_with_rng<R>(
&self,
rng: &mut R,
password: &[u8],
) -> Result<H, Error>where
R: TryCryptoRng + ?Sized,
rand_core only.H from the given password, potentially using configuration stored in
&self for the parameters, or otherwise the recommended defaults. Read more