def safe_str_cmp(a, b):
 if (len(a) != len(b)):
  return False
 rv = 0
 for (x, y) in izip(a, b):
  rv |= (ord(x) ^ ord(y))
 return (rv == 0)

def safe_str_cmp ( a , b ) : if ( len ( a ) != len ( b ) ) : return False rv = 0 for ( x , y ) in izip ( a , b ) : rv |= ( ord ( x ) ^ ord ( y ) ) return ( rv == 0 )
this function compares strings in somewhat constant time .