pub fn decipher(keyphrase: &[u8], cipher_text: &[u8]) -> Result<String, Error> {
    let key = create_key(&sanitize_text(keyphrase)?);

    let cipher_text = sanitize_text(&cipher_text)?;

    // This represents matrix we will try to fill with our cipher text
    // It is a list of queues where the inner queue represents a single column
    // The outer list has `key-length` elements, since there are `key-length` columns
    let mut columns = vec![VecDeque::new(); key.len()];

    {
        // Our goal here is to place the cipher text in the correct columns.
        let cipher_text = cipher_text.clone();

        let mut cursor = 0;

        for i in 0..key.len() {
            // Work out the heigth of the ith column
    
            // All columns are at least `cipher_text.len() / key.len()` high
            let base_height = cipher_text.len() / key.len();
    
            let remainder =  cipher_text.len() % key.len(); 
    
            let height = if remainder == 0 {
                // If the key evenly divides the cipher text, we are done
                base_height
            } else {
                // If it doesn't, use the remainder to figure out if this column is 
                // longer
                if key[..remainder].contains(&i) {
                    base_height + 1
                }
                else {
                    base_height
                }
            };

            let column = cipher_text[cursor..cursor + height].iter().copied().collect();

            cursor += height;

            columns[i] = column;
        }
    }

    let mut deciphered = Vec::new();

    // We now zip through the `columns` structure, popping 
    // items off in the order ordained by our lord and savior, the KEY
    for i in 0..cipher_text.len() {
        let k = key[i % key.len()];
        let p = columns[k].pop_front().unwrap();

        deciphered.push(p);
    }
    
    Ok(format_output(deciphered))
}
/// Deciphers `cipher_text` with `keyphrase` using regular columna transposition
Deciphers `cipher_text` with `keyphrase` using regular columna transposition
Deciphers ` cipher_text ` with ` keyphrase ` using regular columna transposition
pub fn decipher(keyphrase: &[u8], cipher_text: &[u8]) -> Result<String, Error> {
    let key = create_key(&sanitize_text(keyphrase)?);
    let cipher_text = sanitize_text(&cipher_text)?;
    // This represents matrix we will try to fill with our cipher text
    // It is a list of queues where the inner queue represents a single column
    // The outer list has `key-length` elements, since there are `key-length` columns
    let mut columns = vec![VecDeque::new(); key.len()];
    {
        // Our goal here is to place the cipher text in the correct columns.
        let cipher_text = cipher_text.clone();
        let mut cursor = 0;
        for i in 0..key.len() {
            // Work out the heigth of the ith column
            // All columns are at least `cipher_text.len() / key.len()` high
            let base_height = cipher_text.len() / key.len();
            let remainder =  cipher_text.len() % key.len(); 
            let height = if remainder == 0 {
                // If the key evenly divides the cipher text, we are done
                base_height
            } else {
                // If it doesn't, use the remainder to figure out if this column is 
                // longer
                if key[..remainder].contains(&i) {
                    base_height + 1
                }
                else {
                    base_height
                }
            };
            let column = cipher_text[cursor..cursor + height].iter().copied().collect();
            cursor += height;
            columns[i] = column;
        }
    }
    let mut deciphered = Vec::new();
    // We now zip through the `columns` structure, popping 
    // items off in the order ordained by our lord and savior, the KEY
    for i in 0..cipher_text.len() {
        let k = key[i % key.len()];
        let p = columns[k].pop_front().unwrap();
        deciphered.push(p);
    }
    Ok(format_output(deciphered))
}
pub fn decipher ( keyphrase : & [ u8 ] , cipher_text : & [ u8 ] ) -> Result < String , Error > { let key = create_key ( & sanitize_text ( keyphrase ) ? ) ; let cipher_text = sanitize_text ( & cipher_text ) ? ; // This represents matrix we will try to fill with our cipher text // It is a list of queues where the inner queue represents a single column // The outer list has `key-length` elements, since there are `key-length` columns let mut columns = vec ! [ VecDeque new ( ) key len ( ) ] ; { // Our goal here is to place the cipher text in the correct columns. let cipher_text = cipher_text . clone ( ) ; let mut cursor = 0 ; for i in 0 .. key . len ( ) { // Work out the heigth of the ith column // All columns are at least `cipher_text.len() / key.len()` high let base_height = cipher_text . len ( ) / key . len ( ) ; let remainder = cipher_text . len ( ) % key . len ( ) ; let height = if remainder == 0 { // If the key evenly divides the cipher text, we are done base_height } else { // If it doesn't, use the remainder to figure out if this column is  // longer if key [ .. remainder ] . contains ( & i ) { base_height + 1 } else { base_height } } ; let column = cipher_text [ cursor .. cursor + height ] . iter ( ) . copied ( ) . collect ( ) ; cursor += height ; columns [ i ] = column ; } } let mut deciphered = Vec :: new ( ) ; // We now zip through the `columns` structure, popping  // items off in the order ordained by our lord and savior, the KEY for i in 0 .. cipher_text . len ( ) { let k = key [ i % key . len ( ) ] ; let p = columns [ k ] . pop_front ( ) . unwrap ( ) ; deciphered . push ( p ) ; } Ok ( format_output ( deciphered ) ) }
Deciphers `cipher_text` with `keyphrase` using regular columna transposition
Deciphers ` cipher_text ` with ` keyphrase ` using regular columna transposition
keyphrase
&[u8]
cipher_text
&[u8]
keyphrase
&[u8]
cipher_text
&[u8]