pub struct FERNET {
__private_field: (),
}Fields§
§__private_field: ()Methods from Deref<Target = Fernet>§
sourcepub fn encrypt(&self, data: &[u8]) -> String
pub fn encrypt(&self, data: &[u8]) -> String
Encrypts data into a token. Returns a value (which is base64-encoded) that can be
passed to Fernet::decrypt for decryption and verification..
sourcepub fn decrypt(&self, token: &str) -> Result<Vec<u8>, DecryptionError>
pub fn decrypt(&self, token: &str) -> Result<Vec<u8>, DecryptionError>
Decrypts a ciphertext. Returns either Ok(plaintext) if decryption is
successful or Err(DecryptionError) if there are any errors. Errors could
include incorrect key or tampering with the data.
sourcepub fn decrypt_with_ttl(
&self,
token: &str,
ttl_secs: u64
) -> Result<Vec<u8>, DecryptionError>
pub fn decrypt_with_ttl( &self, token: &str, ttl_secs: u64 ) -> Result<Vec<u8>, DecryptionError>
Decrypts a ciphertext with a time-to-live. Returns either Ok(plaintext)
if decryption is successful or Err(DecryptionError) if there are any errors.
Note if the token timestamp + ttl > current time, then this will also yield a
DecryptionError. The ttl is measured in seconds. This is a relative time, not
the absolute time of expiry. IE you would use 60 as a ttl_secs if you wanted
tokens to be considered invalid after that time.