Skip to main content

EncryptionAlgorithm

Trait EncryptionAlgorithm 

Source
pub trait EncryptionAlgorithm: Send + Sync {
    // Required methods
    fn algorithm_id(&self) -> &'static str;
    fn encrypt(&self, data: &[u8], key: &[u8]) -> Result<Vec<u8>>;
    fn decrypt(&self, data: &[u8], key: &[u8]) -> Result<Vec<u8>>;
    fn key_size(&self) -> usize;
    fn nonce_size(&self) -> usize;
}
Expand description

Trait for symmetric encryption algorithms

Required Methods§

Source

fn algorithm_id(&self) -> &'static str

Returns the unique identifier for this algorithm (e.g., “AES-256-GCM”)

Source

fn encrypt(&self, data: &[u8], key: &[u8]) -> Result<Vec<u8>>

Encrypt data with the given key

Source

fn decrypt(&self, data: &[u8], key: &[u8]) -> Result<Vec<u8>>

Decrypt data with the given key

Source

fn key_size(&self) -> usize

Returns the required key size in bytes

Source

fn nonce_size(&self) -> usize

Returns the nonce/IV size in bytes

Implementors§