/// Takes the two keys for the Four-Square cipher and
/// returns a corresponding FourSquare struct.
///
/// # Panics
/// * If `alphabet` is not 25 chars in length.
/// * If `alphabet` is not valid ascii.
/// * If `alphabet` contains repeated chars.
/// * If `key1` is not 25 chars in length.
/// * If `key1` contains repeated chars.
/// * If any of the chars in `key1` are not contained in `alphabet`.
/// * If `key2` is not 25 chars in length.
/// * If `key2` contains repeated chars.
/// * If any of the chars in `key2` are not contained in `alphabet`.
/// * If `pad` is not contained in `alphabet`.
Takes the two keys for the Four-Square cipher and
returns a corresponding FourSquare struct.
Takes the two keys for the Four - Square cipher and returns a corresponding FourSquare struct .
pub fn new(key1: &str, key2: &str, alphabet: &str, pad: char) -> Self {
        assert_eq!(alphabet.len(), 25, "alphabet` must be 25 chars in length");
        input::is_ascii(alphabet).expect("`alphabet` must be valid ascii");
        input::no_repeated_chars(alphabet).expect("`alphabet` cannot contain repeated chars");
        assert_eq!(key1.len(), 25, "`key1` must be 25 chars in length");
        input::no_repeated_chars(key1).expect("`key1` cannot contain repeated chars");
        input::in_alphabet(key1, alphabet)
            .expect("all chars in `key1` must be contained in `alphabet`");
        assert_eq!(key2.len(), 25, "`key2` must be 25 chars in length");
        input::no_repeated_chars(key2).expect("`key2` cannot contain repeated chars");
        input::in_alphabet(key2, alphabet)
            .expect("all chars in `key2` must be contained in `alphabet`");
        assert_ne!(alphabet.find(pad), None, "`alphabet` must contain `pad`");
        Self {
            key1: String::from(key1),
            key2: String::from(key2),
            alphabet: String::from(alphabet),
            pad: pad as u8,
        }
    }
pub fn new ( key1 : & str , key2 : & str , alphabet : & str , pad : char ) -> Self { assert_eq ! ( alphabet len ( ) 25 " " ) ; input :: is_ascii ( alphabet ) . expect ( " " ) ; input :: no_repeated_chars ( alphabet ) . expect ( " " ) ; assert_eq ! ( key1 len ( ) 25 " " ) ; input :: no_repeated_chars ( key1 ) . expect ( " " ) ; input :: in_alphabet ( key1 , alphabet ) . expect ( " " ) ; assert_eq ! ( key2 len ( ) 25 " " ) ; input :: no_repeated_chars ( key2 ) . expect ( " " ) ; input :: in_alphabet ( key2 , alphabet ) . expect ( " " ) ; assert_ne ! ( alphabet find ( pad ) None " " ) ; Self { key1 : String :: from ( key1 ) , key2 : String :: from ( key2 ) , alphabet : String :: from ( alphabet ) , pad : pad as u8 , } }
Takes the two keys for the Four-Square cipher and
returns a corresponding FourSquare struct.
Takes the two keys for the Four - Square cipher and returns a corresponding FourSquare struct .
key1
&str
key2
&str
alphabet
&str
pad
char
panics
If `alphabet` is not 25 chars in length.
If `alphabet` is not valid ascii.
If `alphabet` contains repeated chars.
If `key1` is not 25 chars in length.
If `key1` contains repeated chars.
If any of the chars in `key1` are not contained in `alphabet`.
If `key2` is not 25 chars in length.
If `key2` contains repeated chars.
If any of the chars in `key2` are not contained in `alphabet`.
If `pad` is not contained in `alphabet`.
If ` alphabet ` is not 25 chars in length . If ` alphabet ` is not valid ascii . If ` alphabet ` contains repeated chars . If ` key1 ` is not 25 chars in length . If ` key1 ` contains repeated chars . If any of the chars in ` key1 ` are not contained in ` alphabet ` . If ` key2 ` is not 25 chars in length . If ` key2 ` contains repeated chars . If any of the chars in ` key2 ` are not contained in ` alphabet ` . If ` pad ` is not contained in ` alphabet ` .