Struct cipher_crypt::vigenere::Vigenere
source · pub struct Vigenere { /* private fields */ }
Expand description
A Vigenère cipher.
This struct is created by the new()
method. See its documentation for more.
Trait Implementations§
source§impl Cipher for Vigenere
impl Cipher for Vigenere
source§fn new(key: String) -> Vigenere
fn new(key: String) -> Vigenere
Initialise a Vigenère cipher given a specific key.
Panics
- The
key
is empty. - The
key
contains a non-alphabetic symbol.
source§fn encrypt(&self, message: &str) -> Result<String, &'static str>
fn encrypt(&self, message: &str) -> Result<String, &'static str>
Encrypt a message using a Vigenère cipher.
Examples
Basic usage:
use cipher_crypt::{Cipher, Vigenere};
let v = Vigenere::new(String::from("giovan"));
assert_eq!("O vsqee mmh vnl izsyig!", v.encrypt("I never get any credit!").unwrap());
source§fn decrypt(&self, ciphertext: &str) -> Result<String, &'static str>
fn decrypt(&self, ciphertext: &str) -> Result<String, &'static str>
Decrypt a message using a Vigenère cipher.
Examples
Basic usage:
use cipher_crypt::{Cipher, Vigenere};
let v = Vigenere::new(String::from("giovan"));
assert_eq!("I never get any credit!", v.decrypt("O vsqee mmh vnl izsyig!").unwrap());