I'm trying to use Python to perform binary xor operation on two strings, returning a string of ascii characters. I use binascii python module. I have the following issue with the last conversion binaryString -> ASCII characters.
I have a following code:
byteRepList = ['01111011', '00001101']
''.join(binascii.unhexlify('%x' % int(byte, 2)) for byte in byteRepList)
While 01111011 => '{'
, 00001101 => nothing
.
So TypeError: Odd-length string
is beeing thrown.
Could someone please advise, what should I properly do with it? I would still like to get string output.
In the end my solution to this issue was just to
try-catch
theTypeError
andpass
in the catch block.