pub struct Substitution { /* private fields */ }
Expand description
Substitution Cipher
The struct is generated through the new() function.
Implementations§
Source§impl Substitution
impl Substitution
Sourcepub fn encipher(&self, plaintext: &str) -> Result<String, &'static str>
pub fn encipher(&self, plaintext: &str) -> Result<String, &'static str>
Enciphers a message with a substitution cipher.
§Examples
use kryptos::ciphers::substitution::*;
let s = Substitution::new("NAKYQRTXBZPFIVEJSDCHGOUMWL").unwrap();
assert_eq!(
"Ye weg fbpq cqkdqh iqccntqc",
s.encipher("Do you like secret messages").unwrap()
);
§Panics
Will panic if there is a missing character or invalid character.
Sourcepub fn decipher(&self, plaintext: &str) -> Result<String, &'static str>
pub fn decipher(&self, plaintext: &str) -> Result<String, &'static str>
Deciphers a message with a substitution cipher.
§Examples
use kryptos::ciphers::substitution::*;
let s = Substitution::new("NAKYQRTXBZPFIVEJSDCHGOUMWL").unwrap();
assert_eq!(
"Do you like secret messages",
s.decipher("Ye weg fbpq cqkdqh iqccntqc").unwrap()
);
§Panics
Will panic if there is a missing character or invalid character.
Auto Trait Implementations§
impl Freeze for Substitution
impl RefUnwindSafe for Substitution
impl Send for Substitution
impl Sync for Substitution
impl Unpin for Substitution
impl UnwindSafe for Substitution
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