/// Create a column transposition key out of a keyphrase
///
/// Keys are 0-indexed
/// 
/// # Examples:
/// 
/// - The key phrase "BACD" corresponds to the key  "1023"
/// 
/// - The key phrase "BAACDD" corresponds to the key "201345"
Create a column transposition key out of a keyphrase
Keys are 0-indexed
Create a column transposition key out of a keyphrase Keys are 0 - indexed
fn create_key(keyphrase: &[AsciiUppercaseByte]) -> Vec<usize> {
    let keyphrase = keyphrase.iter().map(|x| x.get_byte()).collect::<Vec<u8>>();
    let mut sorted_keyphrase = keyphrase.clone();
    sorted_keyphrase.sort();
    let mut key = Vec::new();
    for i in 0..keyphrase.len() {
        let idx = sorted_keyphrase.iter().position(|&x| { x == keyphrase[i] }).unwrap();
        key.push(idx);
        // Change the value of the item we just found to 255, so we don't re-find it
        // This is important when the keyphrase has repeated letters.
        // I chose the 255 because it is clearly out of the range of allowed AsciiUppercaseByte values
        sorted_keyphrase[idx] = 255;
    }
    key
}
fn create_key ( keyphrase : & [ AsciiUppercaseByte ] ) -> Vec < usize > { let keyphrase = keyphrase . iter ( ) . map ( | x | x . get_byte ( ) ) . collect :: < Vec < u8 > > ( ) ; let mut sorted_keyphrase = keyphrase . clone ( ) ; sorted_keyphrase . sort ( ) ; let mut key = Vec :: new ( ) ; for i in 0 .. keyphrase . len ( ) { let idx = sorted_keyphrase . iter ( ) . position ( | & x | { x == keyphrase [ i ] } ) . unwrap ( ) ; key . push ( idx ) ; // Change the value of the item we just found to 255, so we don't re-find it // This is important when the keyphrase has repeated letters. // I chose the 255 because it is clearly out of the range of allowed AsciiUppercaseByte values sorted_keyphrase [ idx ] = 255 ; } key }
Create a column transposition key out of a keyphrase
Keys are 0-indexed
Create a column transposition key out of a keyphrase Keys are 0 - indexed
keyphrase
&[AsciiUppercaseByte]
examples:
The key phrase "BACD" corresponds to the key  "1023"

The key phrase "BAACDD" corresponds to the key "201345"
The key phrase " BACD " corresponds to the key " 1023 " The key phrase " BAACDD " corresponds to the key " 201345 "