I really give up

QnickQm at alum.mit.edu QnickQm at alum.mit.edu
Wed Oct 2 12:31:27 EDT 2002


In article <anf67u$i9c$1 at news2.tpi.pl>, piter wrote:
> 
>>
>> One solution: use the low-order bytes of Python's long integers.

>> def make_hash(password, seed):
>>     y = long(seed)
>>     x = 0L
>>     for ch in password:
>>         x = (x & 0xffffff00L) | ord(ch)
>>         y ^= x
>>         y += x
>>         x <<= 8
>>         y ^= x
>>         x <<= 8
>>         y -= x
>>         x <<= 8
>>         y ^= x
>>         z = int(y & 0x1f)
>>         y &= 0xffffffffL
>>         y = ((y << z) | ((y >> (32- z))))
>>
>>     return y & 0xffffffffL
> I tried it also. Doesn't work...

Really?  It works for me, and gives the same results as the C code.
I've tested it on Python2.0 and Python2.2.  What happens, exactly,
when you try to run the code above?

-- 
Nick



More information about the Python-list mailing list