0

I am trying to use the XOR operation using two strings in python.

Here is my script:

packet = "277500011200".decode("hex")
xor = codecs.decode(xor, 'hex')

print packet ^ xor

the xor variable is supposed to be basically a key, where if I xor them together they will decode the packet. However, it is telling me that they are both strings. How do I change the type to hex so that they can work properly?

1 Answer 1

1

int("ff048deadbeef", 16) converts from hex to int.

Edit: seems like OP intended to use x.decode(codec) before converting.

Sign up to request clarification or add additional context in comments.

4 Comments

I've done that, but now I get this error: invalid literal for int() with base 16:
invalid literal for int() with base 16: what?
Could you paste here the particular string that gives that error?
packet = "27750001120007023e12a4f67b12482fb389f8f4a575f4e686fe6305d892d5dda87045864462bf78cfb03f7ce511259a29997d9d7a994db56d13503e643f0dfb3d4e5c7b5b12f0296e26316ff2be4009dd9e935d1357fa49f1af49df7edd6594c2a62b0d786c6b3ccecf8619355b4710c3af163afcf2e6351de55ae9fdd80fae9855952edbd220958c4292582476e29adeb95a634008d6fdd966a147584d8e0646c6bb4292a6847577a1b4a7114848eb1d7b93a12f7a935e9277e14905f25a24677511922f2306973bda16d26f03c78efda934070a693e532d9e7e09d822597836b911a557d55e7d3540a1aa357938990c6fbeb81f63393c85bff1e50e9893b4db547152e4bedfb8ddbddb0ae1eb314c70608ead310db4cc6f".decode("hex")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.