fn candidate_keysizes(input: &[u8]) -> Vec<usize> {
    let count = 3;
    let mut distances: Vec<(usize, u32)> = (2..40)
        .map(|keysize| {
            (
                keysize,
                (100f32 * compute_normalized_hamming_distance(input, keysize)) as u32,
            )
        })
        .collect();

    distances.sort_by(|&(_, s), &(_, t)| s.cmp(&t));
    distances.iter().take(count).map(|x| x.0).collect()
}
// Returns the three key sizes with the smallest normalized hamming distance.
Returns the three key sizes with the smallest normalized hamming distance.
Returns the three key sizes with the smallest normalized hamming distance .
fn candidate_keysizes(input: &[u8]) -> Vec<usize> {
    let count = 3;
    let mut distances: Vec<(usize, u32)> = (2..40)
        .map(|keysize| {
            (
                keysize,
                (100f32 * compute_normalized_hamming_distance(input, keysize)) as u32,
            )
        })
        .collect();
    distances.sort_by(|&(_, s), &(_, t)| s.cmp(&t));
    distances.iter().take(count).map(|x| x.0).collect()
}
fn candidate_keysizes ( input : & [ u8 ] ) -> Vec < usize > { let count = 3 ; let mut distances : Vec < ( usize , u32 ) > = ( 2 .. 40 ) . map ( | keysize | { ( keysize , ( 100f32 * compute_normalized_hamming_distance ( input , keysize ) ) as u32 , ) } ) . collect ( ) ; distances . sort_by ( | & ( _ , s ) , & ( _ , t ) | s . cmp ( & t ) ) ; distances . iter ( ) . take ( count ) . map ( | x | x . 0 ) . collect ( ) }
Returns the three key sizes with the smallest normalized hamming distance.
Returns the three key sizes with the smallest normalized hamming distance .
input
&[u8]
input
&[u8]