Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 0.54 KB | None | 0 0
  1. pub fn brute_single_xor(input: Vec<u8>) -> (u8, Vec<u8>) {
  2.     let (mut lowest_score, mut lowest_val, mut lowest_key) = (f64::INFINITY, Vec::new(), 0);
  3.     for key in 0..256 {
  4.         let cipher_text = xor::xor_byte(&input, key as u8);
  5.         let score = score::score_text(&cipher_text);
  6.         if score < lowest_score {
  7.             lowest_score = score;
  8.             lowest_val = cipher_text.to_vec();
  9.             lowest_key = key;
  10.         }
  11.     }
  12.     (lowest_key, lowest_val) // Change to: (lowest_key as u8, lowest_val) and it works fine
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement