Skip to content

Instantly share code, notes, and snippets.

@dlwhitehurst
Created July 18, 2016 01:41
Show Gist options
  • Save dlwhitehurst/6f31913c6c9411ed05228e9402f19bc1 to your computer and use it in GitHub Desktop.
Save dlwhitehurst/6f31913c6c9411ed05228e9402f19bc1 to your computer and use it in GitHub Desktop.
Unused variable ... conundrum
pub fn wc_single_char_xor_encrypted_line(hex_line_60: &str) -> usize {
let mut best: usize = 0;
for x in 0..255 {
let hexkey = format!("{:02x}",x);
let bigkey = iter::repeat(hexkey).take(30).collect::<String>();
let result = xor(hex_line_60,&bigkey);
let utf8_error = "UTF-8 Error".to_string();
let s = match String::from_utf8(result) {
Ok(v) => v,
Err(e) => utf8_error,
};
let wc = word_count(&s);
if wc > best {
best = wc;
}
}
return best; // highest word count using any error
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment