Struct password_hash::SaltString
source · pub struct SaltString { /* private fields */ }
Expand description
Owned stack-allocated equivalent of Salt
.
Implementations§
source§impl SaltString
impl SaltString
sourcepub fn generate(rng: impl CryptoRng + RngCore) -> Self
pub fn generate(rng: impl CryptoRng + RngCore) -> Self
Generate a random B64-encoded SaltString
.
sourcepub fn new(s: &str) -> Result<Self>
pub fn new(s: &str) -> Result<Self>
Create a new SaltString
.
sourcepub fn b64_encode(input: &[u8]) -> Result<Self>
pub fn b64_encode(input: &[u8]) -> Result<Self>
Encode the given byte slice as B64 into a new SaltString
.
Returns None
if the slice is too long.
sourcepub fn b64_decode<'a>(&self, buf: &'a mut [u8]) -> Result<&'a [u8]>
pub fn b64_decode<'a>(&self, buf: &'a mut [u8]) -> Result<&'a [u8]>
Decode this SaltString
from B64 into the provided output buffer.
sourcepub fn as_salt(&self) -> Salt<'_>
pub fn as_salt(&self) -> Salt<'_>
Borrow the contents of a SaltString
as a Salt
.
sourcepub fn as_str(&self) -> &str
pub fn as_str(&self) -> &str
Borrow the contents of a SaltString
as a str
.
Trait Implementations§
source§impl AsRef<str> for SaltString
impl AsRef<str> for SaltString
source§impl Clone for SaltString
impl Clone for SaltString
source§fn clone(&self) -> SaltString
fn clone(&self) -> SaltString
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for SaltString
impl Debug for SaltString
source§impl<'a> From<&'a SaltString> for Salt<'a>
impl<'a> From<&'a SaltString> for Salt<'a>
source§fn from(salt_string: &'a SaltString) -> Salt<'a>
fn from(salt_string: &'a SaltString) -> Salt<'a>
Converts to this type from the input type.