Struct cipher_crypt::autokey::Autokey
[−]
[src]
pub struct Autokey { /* fields omitted */ }
An Autokey cipher.
This struct is created by the new()
method. See its documentation for more.
Trait Implementations
impl Cipher for Autokey
[src]
type Key = String
type Algorithm = Autokey
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.
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());
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());