pub fn single_byte_xor(b: &[u8]) -> Result<(f64, u8, Vec<u8>), hex::FromHexError> {
    let input = hex::decode(b)?;

    let (mut high_score, mut message, mut key) = (0.0, Vec::new(), 0 as u8);

    for i in 0..=255 {
        let mut plaintext = Vec::new();

        for c in &input {
            plaintext.push(c ^ i);
        }

        let score = score_cipher(&plaintext);

        if score > high_score {
            high_score = score;
            message = plaintext;
            key = i;
        }
    }

    Ok((high_score, key, message))
}
/// Single byte xor cipher
///
/// Solution for problem 3 from set1: <https://cryptopals.com/sets/1/challenges/3>
Single byte xor cipher
Solution for problem 3 from set1.
Single byte xor cipher Solution for problem 3 from set1 .
pub fn single_byte_xor(b: &[u8]) -> Result<(f64, u8, Vec<u8>), hex::FromHexError> {
    let input = hex::decode(b)?;
    let (mut high_score, mut message, mut key) = (0.0, Vec::new(), 0 as u8);
    for i in 0..=255 {
        let mut plaintext = Vec::new();
        for c in &input {
            plaintext.push(c ^ i);
        }
        let score = score_cipher(&plaintext);
        if score > high_score {
            high_score = score;
            message = plaintext;
            key = i;
        }
    }
    Ok((high_score, key, message))
}
pub fn single_byte_xor ( b : & [ u8 ] ) -> Result < ( f64 , u8 , Vec < u8 > ) , hex :: FromHexError > { let input = hex :: decode ( b ) ? ; let ( mut high_score , mut message , mut key ) = ( 0.0 , Vec :: new ( ) , 0 as u8 ) ; for i in 0 ..= 255 { let mut plaintext = Vec :: new ( ) ; for c in & input { plaintext . push ( c ^ i ) ; } let score = score_cipher ( & plaintext ) ; if score > high_score { high_score = score ; message = plaintext ; key = i ; } } Ok ( ( high_score , key , message ) ) }
Single byte xor cipher
Solution for problem 3 from set1: <https://cryptopals.com/sets/1/challenges/3>
Single byte xor cipher Solution for problem 3 from set1 : <https : // cryptopals . com / sets / 1 / challenges / 3 >
b
&[u8]