Could someone help to understand how it works in python (2.7.3 version)?
for,example there are two hex strings
a='5f70a65ac'
b='58e7e5c36'
how can I xor it properly?
I tried use something like that hex (0x5f0x70 ^ 0x580xe70), but it doesn’t work
Convert the strings to integers before trying to do math on them, then back to string afterward.
I’m using
%here to convert back to string rather thanhex()becausehex()adds0xto the beginning (andLto the end if the value is a long integer). You can strip those off, but easier just to not generate them in the first place.You could also just write them as hex literals in the first place:
However, if you’re reading them from a file or getting them from a user or whatever, the first approach is what you need.