pub struct Affine { /* private fields */ }
Expand description
An Affine cipher.
This struct is created by the new()
method. See its documentation for more.
Trait Implementations§
Source§impl Cipher for Affine
impl Cipher for Affine
Source§fn new(key: (usize, usize)) -> Affine
fn new(key: (usize, usize)) -> Affine
Initialise an Affine cipher given the key (a
, b
).
§Panics
a
orb
are not in the inclusive range1 - 26
.a
has a factor in common with 26.
Source§fn encrypt(&self, message: &str) -> Result<String, &'static str>
fn encrypt(&self, message: &str) -> Result<String, &'static str>
Encrypt a message using an Affine cipher.
§Examples
Basic usage:
use cipher_crypt::{Cipher, Affine};
let a = Affine::new((3, 7));
assert_eq!("Hmmhnl hm qhvu!", a.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 an Affine cipher.
§Examples
Basic usage:
use cipher_crypt::{Cipher, Affine};
let a = Affine::new((3, 7));
assert_eq!("Attack at dawn!", a.decrypt("Hmmhnl hm qhvu!").unwrap());
type Key = (usize, usize)
type Algorithm = Affine
Auto Trait Implementations§
impl Freeze for Affine
impl RefUnwindSafe for Affine
impl Send for Affine
impl Sync for Affine
impl Unpin for Affine
impl UnwindSafe for Affine
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