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