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) -> Autokey
fn new(key: String) -> Autokey
Initialise an Autokey cipher given a specific key.
Panics
- The
key
contains non-alphabetic symbols. - The
key
is empty.
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"));
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"));;
assert_eq!("Attack 🗡 the east wall", a.decrypt("Fhktcd 🗡 mhg otzx aade").unwrap());