Alan, 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 showed. 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. Mike On Sat, Oct 24, 2009 at 10:24 AM, Alan Gauld <alan.ga...@btinternet.com>wrote: > > "Tom Green" <xchime...@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 >> "313B372C2E2C63362E2128" >> >> 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. > > HTH, > > > -- > Alan Gauld > Author of the Learn to Program web site > http://www.alan-g.me.uk/ > > _______________________________________________ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor >
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor