Struct cipher_crypt::autokey::Autokey
source · pub struct Autokey { /* private fields */ }Expand description
An Autokey cipher.
This struct is created by the new() method. See its documentation for more.
Trait Implementations§
source§impl Cipher for Autokey
impl Cipher for Autokey
source§fn new(key: String) -> Result<Autokey, &'static str>
fn new(key: String) -> Result<Autokey, &'static str>
Initialise an Autokey cipher given a specific key.
Will return Err if the key contains non-alphabetic symbols.
source§fn encrypt(&self, message: &str) -> Result<String, &'static str>
fn encrypt(&self, message: &str) -> Result<String, &'static str>
Encrypt a message using an Autokey cipher.
Examples
Basic usage:
use cipher_crypt::{Cipher, Autokey};
let a = Autokey::new(String::from("fort")).unwrap();
assert_eq!("Fhktcd 🗡 mhg otzx aade", a.encrypt("Attack 🗡 the east wall").unwrap());source§fn decrypt(&self, ciphertext: &str) -> Result<String, &'static str>
fn decrypt(&self, ciphertext: &str) -> Result<String, &'static str>
Decrypt a message using an Autokey cipher.
Examples
Basic usage:
use cipher_crypt::{Cipher, Autokey};
let a = Autokey::new(String::from("fort")).unwrap();
assert_eq!("Attack 🗡 the east wall", a.decrypt("Fhktcd 🗡 mhg otzx aade").unwrap());