Struct textnonce::TextNonce
[−]
[src]
pub struct TextNonce(pub String);
A nonce is a cryptographic concept of an arbitrary number that is never used more than once.
TextNonce
is a nonce because the first 16 characters represents the current time, which
will never have been generated before, nor will it be generated again, across the period of
time in which Timespec is valid.
TextNonce
additionally includes bytes of randomness, making it difficult to predict.
This makes it suitable to be used for session IDs.
It is also text-based, using only characters in the base64 character set.
Methods
impl TextNonce
[src]
fn new() -> TextNonce
Generate a new TextNonce
with 16 characters of time and 16 characters of
randomness
fn sized(length: usize) -> Result<TextNonce, String>
Generate a new TextNonce
. length
must be at least 16, and divisible by 4.
The first 16 characters come from the time component, and all characters
after that will be random.
fn sized_urlsafe(length: usize) -> Result<TextNonce, String>
Generate a new TextNonce
using the UrlSafe variant of base64 (using '_' and '-')
length
must be at least 16, and divisible by 4. The first 16 characters come
from the time component, and all characters after that will be random.
fn sized_configured(length: usize, config: Config) -> Result<TextNonce, String>
Generate a new TextNonce
specifying the Base64 configuration to use.
length
must be at least 16, and divisible by 4. The first 16 characters come
from the time component, and all characters after that will be random.
fn into_string(self) -> String
Trait Implementations
impl Debug for TextNonce
[src]
impl PartialEq for TextNonce
[src]
fn eq(&self, __arg_0: &TextNonce) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &TextNonce) -> bool
This method tests for !=
.
impl Clone for TextNonce
[src]
fn clone(&self) -> TextNonce
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more