[Tutor] Pack as HEX question

Tom Green xchimeras at gmail.com
Sat Oct 24 16:14:22 CEST 2009

Hello everyone,

First, I wanted to thank everyone in advance for your help and any feedback
is appreciated.  Here is what I am trying to accomplish:

I have this encrypted data that was sent across the network.  The decryption
is a simple XOR with a 16 byte key.  I started writing a basic Python script
that would decrypt the traffic by XORing each byte with the XOR key.  I was
wondering if there was someway in Python to indicate that the string is a
string of HEX values similar to Perl's pack.

For example:

Encrypted string in hex

Four byte key
XOR key "41424344"

Is there any way to tell Python that the encrypted string and XOR key is
HEX? This way I can XOR each byte without having to either place a \x
between every two characters.  I realize I need to convert everything to an
integer first.

I have done this numerous times, but I wanted to throw it out there as I
know there must be a easier way.  I am using Python 2.5.2

Thank you,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20091024/829d9803/attachment.htm>

More information about the Tutor mailing list