Re: [Tutor] Pack as HEX question

2009-10-24 Thread bob gailer
Dave Angel wrote: for byte0, byte1 in itertools.izip(packed_data, itertools.cycle(packed_XorKey)): decrypt.append(chr(ord(byte0) ^ ord(byte1))) And of course that leads to: decrypt = [chr(ord(byte0) ^ ord(byte1)) for byte0, byte1 in itertools.izip(packed_data, itertools.cycle(packed_X

Re: [Tutor] Pack as HEX question

2009-10-24 Thread ALAN GAULD
EncryptString="313B372C2E2C63362E2128" > > >This is different to what I expected, it is a string of ascii bytes >representing hex values. >Is that the real format of your data? If so we need to split it into pairs and >use >int() to convert it. Or is your real data a string of bytes that happen

Re: [Tutor] Pack as HEX question

2009-10-24 Thread Tom Green
Sweet nice tip I love this list. Thank you. Mike On Sat, Oct 24, 2009 at 7:40 PM, Dave Angel wrote: > Tom Green wrote: > >> Thanks for your reply Dave. I am capturing the data off the network >> (wireshark) and saving it in WinHex for testing. I am actually building a >> socket to decrypt th

Re: [Tutor] Pack as HEX question

2009-10-24 Thread Dave Angel
Tom Green wrote: Thanks for your reply Dave. I am capturing the data off the network (wireshark) and saving it in WinHex for testing. I am actually building a socket to decrypt the data, so prior to implementing my logic in the socket, I figured I would write the algorithm in a quick script. H

Re: [Tutor] Pack as HEX question

2009-10-24 Thread Tom Green
Thanks for your reply Dave. I am capturing the data off the network (wireshark) and saving it in WinHex for testing. I am actually building a socket to decrypt the data, so prior to implementing my logic in the socket, I figured I would write the algorithm in a quick script. Here is what I have

Re: [Tutor] Pack as HEX question

2009-10-24 Thread Dave Angel
Tom Green wrote: 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

Re: [Tutor] Pack as HEX question

2009-10-24 Thread Tom Green
This is what I have so far, import struct EncryptString="313B372C2E2C63362E2128" XorKey="41424344" key = struct.unpack("d", XorKey) num_ints = len(EncryptString)/11 data = struct.unpack("%dd"% num_ints,EncryptString) The above code generates an error the my string must be a string length of 16

Re: [Tutor] Pack as HEX question

2009-10-24 Thread ALAN GAULD
> 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. OK, thats because int is for converting strings. You need to use struct.unpack to convert the 4 bytes into an int. You also need to figure out how man

Re: [Tutor] Pack as HEX question

2009-10-24 Thread Tom Green
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 o

Re: [Tutor] Pack as HEX question

2009-10-24 Thread Alan Gauld
"Tom Green" 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

[Tutor] Pack as HEX question

2009-10-24 Thread Tom Green
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 s