[−][src]Struct ciphers::PolybiusSquare
A Polybius Square cipher implementation.
Methods
impl PolybiusSquare
[src]
pub fn new(key: &str, chars: &str) -> Self
[src]
Takes the key and specified characters for the Polybius Square cipher and returns a corresponding PolybiusSquare struct.
Panics
- If
key
is not valid ascii. - If
key
contains repeated chars. - If
chars
is not valid ascii. - If
chars
contains repeated chars. - If
chars
is not of lengthsqrt(key.len())
, orkey
is not oflength chars.len()^2
.
Trait Implementations
impl Cipher for PolybiusSquare
[src]
fn encipher(&self, ptext: &str) -> CipherResult
[src]
Enciphers the given plaintext (a str reference) using the Polybius Square
cipher and returns the ciphertext as a CipherResult
.
Example
use ciphers::{Cipher, PolybiusSquare}; let ps = PolybiusSquare::new("PHQGIUMEAYLNOFDXKRCVSTZWB", "ABCDE"); let ctext = ps.encipher("DEFENDTHEEASTWALLOFTHECASTLE"); assert_eq!(ctext.unwrap(), "CEBCCDBCCBCEEBABBCBCBDEAEBEDBDCACACCCDEBABBCDDBDEAEBCABC");
fn decipher(&self, ctext: &str) -> CipherResult
[src]
Deciphers the given ciphertext (a str reference) using the Polybius Square
cipher and returns the plaintext as a CipherResult
.
Example
use ciphers::{Cipher, PolybiusSquare}; let ps = PolybiusSquare::new("PHQGIUMEAYLNOFDXKRCVSTZWB", "ABCDE"); let ptext = ps.decipher("CEBCCDBCCBCEEBABBCBCBDEAEBEDBDCACACCCDEBABBCDDBDEAEBCABC"); assert_eq!(ptext.unwrap(), "DEFENDTHEEASTWALLOFTHECASTLE");
Auto Trait Implementations
impl Unpin for PolybiusSquare
impl Sync for PolybiusSquare
impl Send for PolybiusSquare
impl UnwindSafe for PolybiusSquare
impl RefUnwindSafe for PolybiusSquare
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,