pub trait Encryptor: Send + Sync {
// Required methods
fn encrypt(&self, plaintext: &[u8]) -> AppResult<String>;
fn decrypt(&self, ciphertext: &str) -> AppResult<Vec<u8>>;
fn algorithm(&self) -> Algorithm;
}Expand description
Trait for symmetric encryption and decryption operations.
Implementations are thread-safe and can be shared across async boundaries.
Required Methods§
Sourcefn encrypt(&self, plaintext: &[u8]) -> AppResult<String>
fn encrypt(&self, plaintext: &[u8]) -> AppResult<String>
Encrypts plaintext and returns base64-encoded ciphertext.
The ciphertext includes a random nonce prepended to the encrypted data, so each call to encrypt with the same plaintext produces different output.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".