diff --git a/set1/chal1/src/main.rs b/set1/chal1/src/main.rs index cfeb3ed..fd6e8e9 100644 --- a/set1/chal1/src/main.rs +++ b/set1/chal1/src/main.rs @@ -103,17 +103,18 @@ fn main() { String::from("42")]; assert_eq!(hex_to_string(&test), "AB"); + // Get command line argument let args: Vec = env::args().collect(); let input = &args[1]; - let char_vec: Vec = input.chars().collect(); + + // Convert Vec to Vec with 2 hexadecimal chars + // ie: ['4','1','4','2'] => ["41", "42"] let hex_char = &char_vec .chunks(2) .map(|chunk| chunk.iter().collect::()) .collect::>(); - let input_str = hex_to_string(&hex_char); - // Convert hex_char : Vec into Vec // Warning: Panic if not base16 // See this with .map_err if we need to improve : @@ -123,6 +124,10 @@ fn main() { .map(|i| u8::from_str_radix(i, 16).unwrap()) .collect(); + // Convert Hexadecimal Vec to String + // ie: ["41", "42"] => "AB" + let input_str = hex_to_string(&hex_char); + let output = base64_encode(&hex); println!("→ Input string is « {} »", input);