From 174772b5b8d9f5bf5e3c8e8152adfd89f0e83f6b Mon Sep 17 00:00:00 2001 From: Justin Wernick Date: Tue, 19 Apr 2022 20:22:56 +0200 Subject: Refile for merging repos --- aoc5/src/main.rs | 49 ------------------------------------------------- 1 file changed, 49 deletions(-) delete mode 100644 aoc5/src/main.rs (limited to 'aoc5/src') diff --git a/aoc5/src/main.rs b/aoc5/src/main.rs deleted file mode 100644 index 31bef5e..0000000 --- a/aoc5/src/main.rs +++ /dev/null @@ -1,49 +0,0 @@ -extern crate md5; - -fn main() { - let room = "reyedfim"; - - let mut i = 0; - let mut found_bytes = 0; - - let mut code: [Option; 8] = [None;8]; - - println!("Cracking the passwordz"); - print_code(&code); - - while found_bytes < 8 { - let room_string = format!("{}{}", room, i); - let room_bytes = room_string.into_bytes(); - let hash = md5::compute(room_bytes.as_slice()); - if match_hash(hash) { - let position = hash[2]; - let value = hash[3] / 16; - if code[position as usize].is_none() { - code[position as usize] = Some(value); - print_code(&code); - found_bytes += 1; - } - } - - i+=1; - } - - println!("Password found!"); -} - -fn match_hash(hash: [u8; 16]) -> bool { - hash[0] == 0 && - hash[1] == 0 && - hash[2] < 8 -} - -fn print_code(code: &[Option; 8]) { - println!(""); - for &byte in code.iter() { - match byte { - None => {print!("-");}, - Some(x) => {print!("{:x}", x);} - } - } - println!(""); -} -- cgit v1.2.3