def mysql_old_passwd(password, uppercase=True):
 (a, b, c) = (1345345333, 7, 305419889)
 for d in password:
  if ((d == ' ') or (d == ' DCTB ')):
   continue
  e = ord(d)
  a ^= ((((a & 63) + b) * e) + (a << 8))
  c += ((c << 8) ^ a)
  b += e
 retVal = ('%08lx%08lx' % ((a & ((1 << 31) - 1)), (c & ((1 << 31) - 1))))
 return (retVal.upper() if uppercase else retVal.lower())

def mysql_old_passwd ( password , uppercase = True ) : ( a , b , c ) = ( 1345345333 , 7 , 305419889 ) for d in password : if ( ( d == ' ' ) or ( d == ' DCTB ' ) ) : continue e = ord ( d ) a ^= ( ( ( ( a & 63 ) + b ) * e ) + ( a << 8 ) ) c += ( ( c << 8 ) ^ a ) b += e retVal = ( '%08lx%08lx' % ( ( a & ( ( 1 << 31 ) - 1 ) ) , ( c & ( ( 1 << 31 ) - 1 ) ) ) ) return ( retVal . upper ( ) if uppercase else retVal . lower ( ) )
reference(s): URL URL .