20 lines
583 B
Rust
20 lines
583 B
Rust
use cryptopals::{prelude::*, bvecs};
|
|
|
|
fn main() {
|
|
let inputs = bvecs!("inputs.txt");
|
|
|
|
let best = (u8::MIN..=u8::MAX).flat_map(
|
|
|possibility| {
|
|
inputs.iter().map(move |input| {
|
|
let result = input.xor_repeating(&vec![possibility]).unwrap();
|
|
let score = cryptopals::english::score(&result);
|
|
(possibility, result, score, input)
|
|
})
|
|
}
|
|
).max_by_key(|(_,_,score, _)| *score).unwrap();
|
|
|
|
dbg!(best.0);
|
|
dbg!(best.1.to_text().unwrap());
|
|
dbg!(best.3.to_hex());
|
|
println!("pass!")
|
|
} |