cryptopals/examples/set1_3/main.rs
2023-04-26 21:58:19 -07:00

16 lines
464 B
Rust

use cryptopals::{prelude::*, bvec};
fn main() {
let input = bvec!("input.txt");
let best = (u8::MIN..=u8::MAX).map(
|possibility| {
let result = input.xor_repeating(&vec![possibility]).unwrap();
let score = cryptopals::english::score(&result);
(possibility, result, score)
}
).max_by_key(|(_,_,score)| *score).unwrap();
dbg!(best.0);
dbg!(best.1.to_text().unwrap());
println!("pass!")
}