diff options
Diffstat (limited to 'tests/lib.rs')
-rw-r--r-- | tests/lib.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/lib.rs b/tests/lib.rs index affe2bc..231be41 100644 --- a/tests/lib.rs +++ b/tests/lib.rs @@ -1,6 +1,9 @@ extern crate matasano; extern crate "rustc-serialize" as serialize; +use std::io::prelude::*; +use std::fs::File; + use serialize::hex::FromHex; #[test] @@ -24,3 +27,13 @@ fn problem_3 () { let plaintext = b"Cooking MC's like a pound of bacon"; assert_eq!(matasano::crack_single_byte_xor(&encrypted[..]), plaintext); } + +#[test] +fn problem_4 () { + let fh = File::open("data/4.txt").unwrap(); + let possibles = std::io::BufStream::new(fh) + .lines() + .map(|line| line.unwrap().from_hex().unwrap()) + .collect::<Vec<Vec<u8>>>(); + assert_eq!(matasano::find_single_byte_xor_encrypted_string(&possibles[..]), b"nOW\0THAT\0THE\0PARTY\0IS\0JUMPING*"); +} |