pub struct Nonce { /* private fields */ }
Expand description
A type that represents a Nonce
that XChaCha20 and XChaCha20Poly1305 use.
Exceptions:
An exception will be thrown if:
slice
is not 24 bytes.- The
OsRng
fails to initialize or read from its source.
Implementations§
source§impl Nonce
impl Nonce
sourcepub fn from_slice(slice: &[u8]) -> Result<Nonce, UnknownCryptoError>
pub fn from_slice(slice: &[u8]) -> Result<Nonce, UnknownCryptoError>
Make an object from a given byte slice.
sourcepub fn generate() -> Result<Nonce, UnknownCryptoError>
pub fn generate() -> Result<Nonce, UnknownCryptoError>
Randomly generate using a CSPRNG. Not available in no_std
context.
sourcepub fn get_length(&self) -> usize
pub fn get_length(&self) -> usize
Return the length of the object.