pub struct PasswordHash(/* private fields */);alloc 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>
pub fn new(s: impl Into<String>) -> Result<PasswordHash>
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>
pub fn from_id(id: &str) -> Result<PasswordHash>
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: Display>(&mut self, displayable: D) -> Result<()>
pub fn push_displayable<D: Display>(&mut self, displayable: D) -> Result<()>
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 more