Alright, wording this is going to be a bit weird, but I'll do my best. I'm doing some mini experimental projects with PyCrypto and am having some issues with some code that I am writing. This code takes an encryption key and a message to be encrypted as input, then outputs both the key and the encrypted message. However, PyCrypto requires bytecode as the input to its encryption functions. Therefore, when I output the encrypted message, it is in bytecode. Due to the nature of how AES encryption works, the message content contains Hexadecimal in the '\x' or '0x' format. This means that the built-in str.decode() method won't work to convert the message back to Unicode.
I did some investigating and could not find a solution to the problem. I instead tried to go around the problem by inputting the bytecode string into the decryption function through the input() method. However, this causes the original bytecode message, b'\x85\xee9', for example, to be converted into the string "b'\x85\xee9". Obviously, I can't just use the str.encode() method on that, as it's the bytecode string I need, just in the wrong format. Is there a way to convert that Unicode string that contains the bytecode into the original bytecode?
If anyone has a solution to either part of the problem, I'd be grateful to hear it. If any error logs are needed, please let me know.
Thanks for the help!