Trait Cipher

Source
pub trait Cipher {
    type Key;
    type Algorithm;

    // Required methods
    fn new(key: Self::Key) -> Self::Algorithm;
    fn encrypt(&self, message: &str) -> Result<String, &'static str>;
    fn decrypt(&self, message: &str) -> Result<String, &'static str>;
}

Required Associated Types§

Required Methods§

Source

fn new(key: Self::Key) -> Self::Algorithm

Initialise a cipher given a specific key.

Source

fn encrypt(&self, message: &str) -> Result<String, &'static str>

Encrypt a message using a cipher’s algorithm.

Source

fn decrypt(&self, message: &str) -> Result<String, &'static str>

Decrypt a message using a cipher’s algorithm.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§