On 7 Sie, 06:01, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Wed, 06 Aug 2008 20:15:11 -0700, Grom wrote: > > Hello everyone :) > > I have one problem with that function in C > ... > > Can someone help me to rewrite it to python? > > > There is the same function, in PHP: > ... > > Please... its very important to me > > I don't know C or PHP. But since it's important, and because you said > please, let me try: > > def calc_passcode(password): > magic1 = 0x50305735 > magic2 = 0x12345671 > sum = 7 > for i in range(len(password)): > z = ord(password[i]) > if z == 32 or z == 9: > continue > magic1 = magic1 ^ ((((magic1 & 0x3f) + sum) * z) + (magic1 << 8)) > magic2 = magic2 + ((magic2 << 8) ^ magic1) > sum += z > magic1 = magic1 & 0x7fffffff > magic2 = magic2 & 0x7fffffff > return '%08x%08x' % (magic1, magic2) > > -- > Steven
It works, thanks :) -- http://mail.python.org/mailman/listinfo/python-list