cryptopals/examples/set1_3/main.rs

16 lines
464 B
Rust
Raw Normal View History

2023-04-27 04:58:19 +00:00
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!")
}