/// Enciphers the given plaintext (a str reference) using the Vignere cipher
/// and returns the ciphertext as a `CipherResult`.
///
/// # Example
/// ```
/// use ciphers::{Cipher, Vigenere};
///
/// let vigenere = Vigenere::new("FORTIFICATION");
///
/// let ctext = vigenere.encipher("DEFENDTHEEASTWALLOFTHECASTLE");
/// assert_eq!(ctext.unwrap(), "ISWXVIBJEXIGGBOCEWKBJEVIGGQS");
/// ```
Enciphers the given plaintext (a str reference) using the Vignere cipher
and returns the ciphertext as a `CipherResult`.
Enciphers the given plaintext ( a str reference ) using the Vignere cipher and returns the ciphertext as a ` CipherResult ` .
fn encipher(&self, ptext: &str) -> CipherResult {
        input::is_alpha(ptext)?;
        let ptext = ptext.to_ascii_uppercase();
        let key = self.key.as_bytes();
        let ctext = ptext
            .bytes()
            .enumerate()
            .map(move |(i, c)| {
                let y = key[i % key.len()] as usize - 65;
                let x = c as usize - 65;
                TABULA_RECTA[y][x]
            })
            .collect();
        Ok(String::from_utf8(ctext).unwrap())
    }
fn encipher ( & self , ptext : & str ) -> CipherResult { input :: is_alpha ( ptext ) ? ; let ptext = ptext . to_ascii_uppercase ( ) ; let key = self . key . as_bytes ( ) ; let ctext = ptext . bytes ( ) . enumerate ( ) . map ( move | ( i , c ) | { let y = key [ i % key . len ( ) ] as usize - 65 ; let x = c as usize - 65 ; TABULA_RECTA [ y ] [ x ] } ) . collect ( ) ; Ok ( String :: from_utf8 ( ctext ) . unwrap ( ) ) }
Enciphers the given plaintext (a str reference) using the Vignere cipher
and returns the ciphertext as a `CipherResult`.
Enciphers the given plaintext ( a str reference ) using the Vignere cipher and returns the ciphertext as a ` CipherResult ` .
&self
ptext
&str
example
```
use ciphers::{Cipher, Vigenere}.

let vigenere = Vigenere::new("FORTIFICATION").

let ctext = vigenere.encipher("DEFENDTHEEASTWALLOFTHECASTLE");
assert_eq!(ctext.unwrap(), "ISWXVIBJEXIGGBOCEWKBJEVIGGQS");
```
` ` ` use ciphers :: { Cipher Vigenere } . let vigenere = Vigenere :: new ( " FORTIFICATION " ) . let ctext = vigenere . encipher ( " DEFENDTHEEASTWALLOFTHECASTLE " ) ; assert_eq! ( ctext . unwrap () " ISWXVIBJEXIGGBOCEWKBJEVIGGQS " ) ; ` ` `