1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
pub trait Cipher {
type Key;
type Algorithm;
/// Initialise a cipher given a specific `key`.
///
fn new(key: Self::Key) -> Self::Algorithm;
/// Encrypt a `message` using a cipher's algorithm.
///
fn encrypt(&self, message: &str) -> Result<String, &'static str>;
/// Decrypt a `message` using a cipher's algorithm.
///
fn decrypt(&self, message: &str) -> Result<String, &'static str>;
}