Hex
When we encrypt something the resulting ciphertext commonly has bytes which are not printable ASCII characters. If we want to share our encrypted data, it's common to encode it into something more user-friendly and portable across different systems.
Hexadecimal can be used in such a way to represent ASCII strings. First each letter is converted to an ordinal number according to the ASCII table (as in the previous challenge). Then the decimal numbers are converted to base-16 numbers, otherwise known as hexadecimal. The numbers can be combined together, into one long hex string.
challenge : below is a flag encoded as a hex string. Decode this back into bytes to get the flag.63727970746f7b596f755f77696c6c5f62655f776f726b696e675f776974685f6865785f737472696e67735f615f6c6f747d
1) Solution (Python):To solve the challenge, I have created a python script that converts hex strings to bytes.
hx = "63727970746f7b596f755f77696c6c5f62655f776f726b696e675f776974685f6865785f737472696e67735f615f6c6f747d"
print(bytes.fromhex(hx)) # b'crypto{You_will_be_working_with_hex_strings_a_lot}'
Flag : crypto{You_will_be_working_with_hex_strings_a_lot}
2) Bash solution :
echo "63727970746f7b596f755f77696c6c5f62655f776f726b696e675f776974685f6865785f737472696e67735f615f6c6f747d" | xxd -r -p
# crypto{You_will_be_working_with_hex_strings_a_lot}
3) Rust solution :
use hex;
fn main(){
let hx = "63727970746f7b596f755f77696c6c5f62655f776f726b696e675f776974685f6865785f737472696e67735f615f6c6f747d";
match hex::decode(hx) {
Ok(byt) => {
let flag = std::str::from_utf8(&byt).unwrap_or_else(|_| panic!("Invalid UTF-8 sequence"));
println!("{}", flag); // crypto{You_will_be_working_with_hex_strings_a_lot}
},
Err(_) => todo!()
}
}