


from __future__ import annotations







class     _lowercase				:


       """simple docstring"""




       def __init__(     self							:    str      ,   __lowerCamelCase							:    int = 0 ):


             '''simple docstring'''



             lowerCamelCase__	:       Optional[int]					=						key





       def 		lowerCAmelCase  (     self							:    Optional[Any]      ,   __lowerCamelCase							:    str      ,   __lowerCamelCase							:    int ):


             '''simple docstring'''



             assert isinstance(UpperCAmelCase_      ,   UpperCAmelCase_ ) and isinstance(UpperCAmelCase_      ,   UpperCAmelCase_ )

             lowerCamelCase__	:       Tuple					=						key or self.__key or 1

             # make sure key is an appropriate size
             key %= 255

             return [chr(ord(UpperCAmelCase_ ) ^ key ) for ch in content]





       def 		lowerCAmelCase  (     self							:    Any      ,   __lowerCamelCase							:    str      ,   __lowerCamelCase							:    int ):


             '''simple docstring'''



             assert isinstance(UpperCAmelCase_      ,   UpperCAmelCase_ ) and isinstance(UpperCAmelCase_      ,   UpperCAmelCase_ )

             lowerCamelCase__	:       Optional[Any]					=						key or self.__key or 1

             # make sure key is an appropriate size
             key %= 255

             return [chr(ord(UpperCAmelCase_ ) ^ key ) for ch in content]





       def 		lowerCAmelCase  (     self							:    Any      ,   __lowerCamelCase							:    str      ,   __lowerCamelCase							:    int = 0 ):


             '''simple docstring'''



             assert isinstance(UpperCAmelCase_      ,   UpperCAmelCase_ ) and isinstance(UpperCAmelCase_      ,   UpperCAmelCase_ )

             lowerCamelCase__	:       List[str]					=						key or self.__key or 1

             # make sure key can be any size
             while key > 255:
                   key -= 255

             # This will be returned
             lowerCamelCase__	:       Union[str, Any]					=						''

             for ch in content:
                   ans += chr(ord(UpperCAmelCase_ ) ^ key )

             return ans





       def 		lowerCAmelCase  (     self							:    Tuple      ,   __lowerCamelCase							:    str      ,   __lowerCamelCase							:    int = 0 ):


             '''simple docstring'''



             assert isinstance(UpperCAmelCase_      ,   UpperCAmelCase_ ) and isinstance(UpperCAmelCase_      ,   UpperCAmelCase_ )

             lowerCamelCase__	:       Union[str, Any]					=						key or self.__key or 1

             # make sure key can be any size
             while key > 255:
                   key -= 255

             # This will be returned
             lowerCamelCase__	:       Dict					=						''

             for ch in content:
                   ans += chr(ord(UpperCAmelCase_ ) ^ key )

             return ans





       def 		lowerCAmelCase  (     self							:    Any      ,   __lowerCamelCase							:    str      ,   __lowerCamelCase							:    int = 0 ):


             '''simple docstring'''



             assert isinstance(UpperCAmelCase_      ,   UpperCAmelCase_ ) and isinstance(UpperCAmelCase_      ,   UpperCAmelCase_ )

             try:
                   with open(UpperCAmelCase_ ) as fin, open("encrypt.out"      ,   "w+" ) as fout:
                         # actual encrypt-process
                         for line in fin:
                               fout.write(self.encrypt_string(UpperCAmelCase_      ,   UpperCAmelCase_ ) )

             except OSError:
                   return False

             return True





       def 		lowerCAmelCase  (     self							:    List[str]      ,   __lowerCamelCase							:    str      ,   __lowerCamelCase							:    int ):


             '''simple docstring'''



             assert isinstance(UpperCAmelCase_      ,   UpperCAmelCase_ ) and isinstance(UpperCAmelCase_      ,   UpperCAmelCase_ )

             try:
                   with open(UpperCAmelCase_ ) as fin, open("decrypt.out"      ,   "w+" ) as fout:
                         # actual encrypt-process
                         for line in fin:
                               fout.write(self.decrypt_string(UpperCAmelCase_      ,   UpperCAmelCase_ ) )

             except OSError:
                   return False

             return True


# Tests
# crypt = XORCipher()
# key = 67

# # test encrypt
# print(crypt.encrypt("hallo welt",key))
# # test decrypt
# print(crypt.decrypt(crypt.encrypt("hallo welt",key), key))

# # test encrypt_string
# print(crypt.encrypt_string("hallo welt",key))

# # test decrypt_string
# print(crypt.decrypt_string(crypt.encrypt_string("hallo welt",key),key))

# if (crypt.encrypt_file("test.txt",key)):
#       print("encrypt successful")
# else:
#       print("encrypt unsuccessful")

# if (crypt.decrypt_file("encrypt.out",key)):
#       print("decrypt successful")
# else:
#       print("decrypt unsuccessful")






def    lowercase_	(	_A    :					int		):

      """simple docstring"""




      if not isinstance(_A					,      _A		):
            lowerCamelCase__	:       List[str]					=						F"Input value of [number={number}] must be an integer"
            raise TypeError(_A		)
      if number < 0:
            return False
      lowerCamelCase__	:       Dict					=						number * number
      while number > 0:
            if number % 10 != number_square % 10:
                  return False
            number //= 10
            number_square //= 10
      return True


if __name__ == "__main__":
    import doctest

    doctest.testmod()


