code: def constant_time_compare(val1, val2):  # noqa: C901
      
      if len(val1) != len(val2):
          return False
  
      if isinstance(val1, bytes):
          val1 = val1.decode("ascii")
      if isinstance(val2, bytes):
          val2 = val2.decode("ascii")
  
      result = 0
      for x, y in zip(val1, val2):
          result |= ord(x) ^ ord(y)
      return result == 0
docs: **This code was taken from the django 1.4.x codebase along with the test code**
      Returns True if the two strings are equal, False otherwise.
  
      The time taken is independent of the number of characters that match.