Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pub fn brute_single_xor(input: Vec<u8>) -> (u8, Vec<u8>) {
- let (mut lowest_score, mut lowest_val, mut lowest_key) = (f64::INFINITY, Vec::new(), 0);
- for key in 0..256 {
- let cipher_text = xor::xor_byte(&input, key as u8);
- let score = score::score_text(&cipher_text);
- if score < lowest_score {
- lowest_score = score;
- lowest_val = cipher_text.to_vec();
- lowest_key = key;
- }
- }
- (lowest_key, lowest_val) // Change to: (lowest_key as u8, lowest_val) and it works fine
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement