pub struct ShortCrypt { /* private fields */ }Expand description
A deterministic encryption context derived from a string key.
Implementations§
Source§impl ShortCrypt
impl ShortCrypt
Sourcepub fn new<S: AsRef<str>>(key: S) -> ShortCrypt
pub fn new<S: AsRef<str>>(key: S) -> ShortCrypt
Creates a new ShortCrypt instance from a string key.
Sourcepub fn encrypt<T: ?Sized + AsRef<[u8]>>(&self, plaintext: &T) -> Cipher
pub fn encrypt<T: ?Sized + AsRef<[u8]>>(&self, plaintext: &T) -> Cipher
Encrypts byte-like plaintext into a Cipher.
Sourcepub fn decrypt(&self, data: &Cipher) -> Result<Vec<u8>, &'static str>
pub fn decrypt(&self, data: &Cipher) -> Result<Vec<u8>, &'static str>
Decrypts a Cipher and rejects data whose 5-bit checksum does not match.
Sourcepub fn encrypt_to_url_component<T: ?Sized + AsRef<[u8]>>(
&self,
data: &T,
) -> String
pub fn encrypt_to_url_component<T: ?Sized + AsRef<[u8]>>( &self, data: &T, ) -> String
Encrypts data and encodes the cipher as a Base64-URL component.
Sourcepub fn encrypt_to_url_component_and_push_to_string<T: ?Sized + AsRef<[u8]>, S: Into<String>>(
&self,
data: &T,
output: S,
) -> String
pub fn encrypt_to_url_component_and_push_to_string<T: ?Sized + AsRef<[u8]>, S: Into<String>>( &self, data: &T, output: S, ) -> String
Encrypts data and appends the Base64-URL component to a string.
Sourcepub fn decrypt_url_component<S: AsRef<str>>(
&self,
url_component: S,
) -> Result<Vec<u8>, &'static str>
pub fn decrypt_url_component<S: AsRef<str>>( &self, url_component: S, ) -> Result<Vec<u8>, &'static str>
Decodes and decrypts a Base64-URL component.
Sourcepub fn decrypt_url_component_and_push_to_vec<S: AsRef<str>>(
&self,
url_component: S,
output: Vec<u8>,
) -> Result<Vec<u8>, &'static str>
pub fn decrypt_url_component_and_push_to_vec<S: AsRef<str>>( &self, url_component: S, output: Vec<u8>, ) -> Result<Vec<u8>, &'static str>
Decodes and decrypts a Base64-URL component and appends the plaintext to a vector.
Sourcepub fn encrypt_to_qr_code_alphanumeric<T: ?Sized + AsRef<[u8]>>(
&self,
data: &T,
) -> String
pub fn encrypt_to_qr_code_alphanumeric<T: ?Sized + AsRef<[u8]>>( &self, data: &T, ) -> String
Encrypts data and encodes the cipher as Base32 text for QR alphanumeric mode.
Sourcepub fn encrypt_to_qr_code_alphanumeric_and_push_to_string<T: ?Sized + AsRef<[u8]>, S: Into<String>>(
&self,
data: &T,
output: S,
) -> String
pub fn encrypt_to_qr_code_alphanumeric_and_push_to_string<T: ?Sized + AsRef<[u8]>, S: Into<String>>( &self, data: &T, output: S, ) -> String
Encrypts data and appends Base32 text for QR alphanumeric mode to a string.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ShortCrypt
impl RefUnwindSafe for ShortCrypt
impl Send for ShortCrypt
impl Sync for ShortCrypt
impl Unpin for ShortCrypt
impl UnsafeUnpin for ShortCrypt
impl UnwindSafe for ShortCrypt
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more