[Tutor] Pack as HEX question
xchimeras at gmail.com
Sat Oct 24 17:05:25 CEST 2009
Thanks for your response and hopefully I can clear things up. I apologize
for not being more clear.
I obtain the HEX encoded data from Winhex i.e. copy Hex values. The HEX
encode data is very large and I simply paste it into my Python script along
with the XOR key. The data is a string of bytes represented in HEX, as I
Here is the problem I ran into.
Take the 4 byte XOR key. If I convert them to int with Base 16 it takes the
4 and converts it to 0x34 when I in turn I actually need 0x41.
Thanks for your feedback.
On Sat, Oct 24, 2009 at 10:24 AM, Alan Gauld <alan.gauld at btinternet.com>wrote:
> "Tom Green" <xchimeras at gmail.com> wrote
> wondering if there was someway in Python to indicate that the string is a
>> string of HEX values similar to Perl's pack.
> You need to be very careful in your terminology here.
> Is it "a string of hex values" ie a string representation of a hex
> value or is it a string of bytes which can be represented in hex
> as you showed? The two and their processing are entirely different!
> Encrypted string in hex
>> Four byte key
>> XOR key "41424344"
> Assuming the data really is binary data represented by the hex
> value you display above then you can use the struct module to
> unpack the values into integers directly.
> If it is a string of characters representing hex values then you can use
> the int() function to convert them by providing a base argument of 16..
> 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
> There is almost certainly an easier way but which way we
> that is cannot tell for sure from the information given.
> Alan Gauld
> Author of the Learn to Program web site
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor