pub struct SaltString {
chars: [u8; 64],
length: u8,
}Expand description
Owned stack-allocated equivalent of Salt.
Fields§
§chars: [u8; 64]ASCII-encoded characters which comprise the salt.
length: u8Length of the string in ASCII characters (i.e. bytes).
Implementations§
Source§impl SaltString
impl SaltString
Sourcepub fn generate(rng: impl CryptoRngCore) -> Self
pub fn generate(rng: impl CryptoRngCore) -> Self
Generate a random B64-encoded SaltString.
Sourcepub fn from_b64(s: &str) -> Result<Self>
pub fn from_b64(s: &str) -> Result<Self>
Create a new SaltString from the given B64-encoded input string,
validating Salt::MIN_LENGTH and Salt::MAX_LENGTH restrictions.
Sourcepub fn decode_b64<'a>(&self, buf: &'a mut [u8]) -> Result<&'a [u8]>
pub fn decode_b64<'a>(&self, buf: &'a mut [u8]) -> Result<&'a [u8]>
Decode this SaltString from B64 into the provided output buffer.
Sourcepub fn encode_b64(input: &[u8]) -> Result<Self>
pub fn encode_b64(input: &[u8]) -> Result<Self>
Encode the given byte slice as B64 into a new SaltString.
Returns Error if the slice is too long.
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.
Sourcepub fn new(s: &str) -> Result<Self>
👎Deprecated since 0.5.0: use from_b64 instead
pub fn new(s: &str) -> Result<Self>
from_b64 insteadCreate a new SaltString from the given B64-encoded input string,
validating Salt::MIN_LENGTH and Salt::MAX_LENGTH restrictions.
Sourcepub fn b64_decode<'a>(&self, buf: &'a mut [u8]) -> Result<&'a [u8]>
👎Deprecated since 0.5.0: use decode_b64 instead
pub fn b64_decode<'a>(&self, buf: &'a mut [u8]) -> Result<&'a [u8]>
decode_b64 insteadDecode this SaltString from B64 into the provided output buffer.
Sourcepub fn b64_encode(input: &[u8]) -> Result<Self>
👎Deprecated since 0.5.0: use encode_b64 instead
pub fn b64_encode(input: &[u8]) -> Result<Self>
encode_b64 insteadEncode the given byte slice as B64 into a new SaltString.
Returns Error if the slice is too long.
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
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more