[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

Re: [Tutor] Pack as HEX question

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

[Tutor] Using IDLE v2.6

2009-10-24 Thread Ken G.
I just reinstalled Python v2.6.2 due to a computer crash. I reinstalled IDLE v2.6 but I was wondering if there is something better than IDLE. I am using Ubuntu 9.04 so they do have some limited choices available. Thanks for your input. Ken ___

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 many

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 When

Re: [Tutor] ifdef in python

2009-10-24 Thread Albert-Jan Roskam
Isn't it better to use if __debug__: I thought such an if statement always evaluated to False when the python program was run in OPTIMIZED (-o) mode? Cheers!! Albert-Jan ~~ Before you criticize someone, walk a mile in their

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] Using IDLE v2.6

2009-10-24 Thread Kurt Bendl
Ken G. beach...@insightbb.com wrote IDLE v2.6 but I was wondering if there is something better than IDLE. I've been happy with WingIDE on Linux, fwiw. I'm still a TextMate fanboy (if you use a Mac). -kb ___ Tutor maillist - Tutor@python.org To

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.

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 da...@ieee.org 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

Re: [Tutor] Using IDLE v2.6

2009-10-24 Thread Robert Berman
Ken, Two recommendations. 1) Komodo Edit 5. Free edition available from Activestate. www.activestate,com 2) Wing IDE 101 Free Edition from www.wingware.com my favorite of the freely available IDE's. Good luck, Robert On Sat, 2009-10-24 at 13:57 -0400, Ken G. wrote: I

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 to have

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,

[Tutor] Moving a Shelf Between Linux and Mac OS X

2009-10-24 Thread Patrick Kenny
Greetings, I recently started learning Python and I have written a script that uses a shelf on Mac OS X using Python 2.6. I recently attempted to move the directory over to my Linux system, which also has Python 2.6 installed, and run the script there. The script works fine, but the shelf does