pub struct Caesar { /* private fields */ }
Expand description
A Caesar cipher.
This struct is created by the new()
method. See its documentation for more.
Trait Implementations§
Source§impl Cipher for Caesar
impl Cipher for Caesar
Source§fn new(shift: usize) -> Caesar
fn new(shift: usize) -> Caesar
Initialise a Caesar cipher given a specific shift value.
§Panics
shift
is not in the inclusive range1 - 26
.
Source§fn encrypt(&self, message: &str) -> Result<String, &'static str>
fn encrypt(&self, message: &str) -> Result<String, &'static str>
Encrypt a message using a Caesar cipher.
§Examples
Basic usage:
use cipher_crypt::{Cipher, Caesar};
let c = Caesar::new(3);
assert_eq!("Dwwdfn dw gdzq!", c.encrypt("Attack at dawn!").unwrap());
Source§fn decrypt(&self, ciphertext: &str) -> Result<String, &'static str>
fn decrypt(&self, ciphertext: &str) -> Result<String, &'static str>
Decrypt a message using a Caesar cipher.
§Examples
Basic usage:
use cipher_crypt::{Cipher, Caesar};
let c = Caesar::new(3);
assert_eq!("Attack at dawn!", c.decrypt("Dwwdfn dw gdzq!").unwrap());
type Key = usize
type Algorithm = Caesar
Auto Trait Implementations§
impl Freeze for Caesar
impl RefUnwindSafe for Caesar
impl Send for Caesar
impl Sync for Caesar
impl Unpin for Caesar
impl UnwindSafe for Caesar
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