def postgres_passwd(password, username, uppercase=False):
 retVal = ('md5%s' % md5((password + username)).hexdigest())
 return (retVal.upper() if uppercase else retVal.lower())

def postgres_passwd ( password , username , uppercase = False ) : retVal = ( 'md5%s' % md5 ( ( password + username ) ) . hexdigest ( ) ) return ( retVal . upper ( ) if uppercase else retVal . lower ( ) )
reference(s): URL .