code: def safe_compare_digest(val1, val2):
      
      if len(val1) != len(val2):
          return False
  
      result = 0
      if PY3 and isinstance(val1, bytes) and isinstance(val2, bytes):
          for i, j in zip(val1, val2):
              result |= i ^ j
      else:
          for i, j in zip(val1, val2):
              result |= (ord(i) ^ ord(j))
  
      return result == 0
docs: safe_compare_digest method.
  
      :param val1: string or bytes for compare
      :type val1: str | bytes
      :param val2: string or bytes for compare
      :type val2: str | bytes