/// 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 length `sqrt(key.len())`, or `key` is not of `length chars.len()^2`.
Takes the key and specified characters for the Polybius Square
cipher and returns a corresponding PolybiusSquare struct.
Takes the key and specified characters for the Polybius Square cipher and returns a corresponding PolybiusSquare struct .
pub fn new(key: &str, chars: &str) -> Self {
        input::is_ascii(key).expect("`key` must be valid ascii");
        input::no_repeated_chars(key).expect("`key` cannot contain repeated chars");
        input::is_ascii(chars).expect("`chars` must be valid ascii");
        input::no_repeated_chars(chars).expect("`chars` cannot contain repeated chars");
        assert_eq!(
            key.len(),
            chars.len() * chars.len(),
            "`chars` must be of length sqrt(key.len())"
        );
        Self {
            key: String::from(key),
            chars: String::from(chars),
        }
    }
pub fn new ( key : & str , chars : & str ) -> Self { input :: is_ascii ( key ) . expect ( " " ) ; input :: no_repeated_chars ( key ) . expect ( " " ) ; input :: is_ascii ( chars ) . expect ( " " ) ; input :: no_repeated_chars ( chars ) . expect ( " " ) ; assert_eq ! ( key len ( ) chars len ( ) chars len ( ) " " ) ; Self { key : String :: from ( key ) , chars : String :: from ( chars ) , } }
Takes the key and specified characters for the Polybius Square
cipher and returns a corresponding PolybiusSquare struct.
Takes the key and specified characters for the Polybius Square cipher and returns a corresponding PolybiusSquare struct .
key
&str
chars
&str
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 length `sqrt(key.len())`, or `key` is not of `length chars.len()^2`.
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 length ` sqrt ( key . len () ) ` or ` key ` is not of ` length chars . len () ^2 ` .