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());
type Key = String
type Algorithm = Autokey
Auto Trait Implementations§
impl Freeze for Autokey
impl RefUnwindSafe for Autokey
impl Send for Autokey
impl Sync for Autokey
impl Unpin for Autokey
impl UnwindSafe for Autokey
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more