def constant_time_compare(val1, val2):
 if (len(val1) != len(val2)):
  return False
 result = 0
 if (six.PY3 and isinstance(val1, bytes) and isinstance(val2, bytes)):
  for (x, y) in zip(val1, val2):
   result |= (x ^ y)
 else:
  for (x, y) in zip(val1, val2):
   result |= (ord(x) ^ ord(y))
 return (result == 0)

def constant_time_compare ( val1 , val2 ) : if ( len ( val1 ) != len ( val2 ) ) : return False result = 0 if ( six . PY3 and isinstance ( val1 , bytes ) and isinstance ( val2 , bytes ) ) : for ( x , y ) in zip ( val1 , val2 ) : result |= ( x ^ y ) else : for ( x , y ) in zip ( val1 , val2 ) : result |= ( ord ( x ) ^ ord ( y ) ) return ( result == 0 )
returns true if the two strings are equal .