One systematic, if maybe clumsy way, is to mimic the C arithmetic
operations more closely in Python. If you do, for example, a left shift
in C, the result is always returned in a certain precision, 64 bits in
the example below. In python, no bits are lost, so you have to force the
result into t
Kinsley Turner wrote:
> I'm getting a bit out of my depth porting the 'tiny encryption algorithm'
> from C to python
> In my version, I end up with hugely long integers, which have obviously
> not be constrained into the 4-byte unsigned longs that TEA is expecting.
> ...
> def teaDecipher(inp
Hi!
Kinsley Turner wrote:
[snip]
>
> def teaDecipher(input,key):
> y = input[0]
> z = input[1]
> n = 32
> sum = 0xC6EF3720
> delta=0x9E3779B9
>
> while (n > 0):
> n -= 1
> z -= (y << 4 ^ y >> 5) + y ^ sum + key[sum>>11 & 3];
> sum -= delta;
>
Kinsley Turner <[EMAIL PROTECTED]> writes:
> In my version, I end up with hugely long integers, which have obviously
> not be constrained into the 4-byte unsigned longs that TEA is expecting.
Yeah, Python promotes to long int now. The simplest way to do the
32-bit arithmetic you need is probably
Hey-ho,
I'm getting a bit out of my depth porting the 'tiny encryption algorithm'
from C to python.
Ref:
http://en.wikipedia.org/wiki/Tiny_Encryption_Algorithm
http://www.simonshepherd.supanet.com/source.htm#new_ansi
Specifically I don;t know how to handle a C-long block and perform the
math