fn encipher(&self, ptext: &str) -> CipherResult {
        if self.key.len() < ptext.len() {
            return Err(CipherInputError::BadInput(String::from(
                "`ptext` cannot be longer than the key",
            )));
        }
        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] 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 Running Key
/// cipher and returns the ciphertext as a `CipherResult`.
///
/// # Example
/// ```
/// use ciphers::{Cipher, RunningKey};
///
/// let running_key = RunningKey::new("HOWDOESTHEDUCKKNOWTHATSAIDVICTOR");
///
/// let ctext = running_key.encipher("DEFENDTHEEASTWALLOFTHECASTLE");
/// assert_eq!(ctext.unwrap(), "KSBHBHLALIDMVGKYZKYAHXUAAWGM");
/// ```
Enciphers the given plaintext (a str reference) using the Running Key
cipher and returns the ciphertext as a `CipherResult`.
Enciphers the given plaintext ( a str reference ) using the Running Key cipher and returns the ciphertext as a ` CipherResult ` .
fn encipher(&self, ptext: &str) -> CipherResult {
        if self.key.len() < ptext.len() {
            return Err(CipherInputError::BadInput(String::from(
                "`ptext` cannot be longer than the key",
            )));
        }
        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] 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 { if self . key . len ( ) < ptext . len ( ) { return Err ( CipherInputError :: BadInput ( String :: from ( " " , ) ) ) ; } 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 ] 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 Running Key
cipher and returns the ciphertext as a `CipherResult`.
Enciphers the given plaintext ( a str reference ) using the Running Key cipher and returns the ciphertext as a ` CipherResult ` .
&self
ptext
&str
&self
ptext
&str
example
```
use ciphers::{Cipher, RunningKey}.



let ctext = running_key.encipher("DEFENDTHEEASTWALLOFTHECASTLE");
assert_eq!(ctext.unwrap(), "KSBHBHLALIDMVGKYZKYAHXUAAWGM");
```
` ` ` use ciphers :: { Cipher RunningKey } . let ctext = running_key . encipher ( " DEFENDTHEEASTWALLOFTHECASTLE " ) ; assert_eq! ( ctext . unwrap () " KSBHBHLALIDMVGKYZKYAHXUAAWGM " ) ; ` ` `