def       UpperCAmelCase					(	UpperCAmelCase		,      UpperCAmelCase      )       ->   int:
     return (input_a, input_a).count(0      ) % 2







def       UpperCAmelCase					(	)       ->   Optional[int]:
     assert xor_gate(0		,      0      ) == 0
     assert xor_gate(0		,      1      ) == 1
     assert xor_gate(1		,      0      ) == 1
     assert xor_gate(1		,      1      ) == 0


if __name__ == "__main__":
    print(xor_gate(0, 0))
    print(xor_gate(0, 1))


"""simple docstring"""


import random
import sys

from . import cryptomath_module as cryptomath

__UpperCamelCase								=    (
    r''' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`'''
    r'''abcdefghijklmnopqrstuvwxyz{|}~'''
)







def       UpperCAmelCase					(	UpperCAmelCase		,      UpperCAmelCase		,      UpperCAmelCase      )       ->   None:
     if mode == "encrypt":
          if key_a == 1:
               sys.exit(
                   'The affine cipher becomes weak when key '
                   'A is set to 1. Choose different key'      )
          if key_b == 0:
               sys.exit(
                   'The affine cipher becomes weak when key '
                   'B is set to 0. Choose different key'      )
     if key_a < 0 or key_b < 0 or key_b > len(UpperCAmelCase      ) - 1:
          sys.exit(
              'Key A must be greater than 0 and key B must '
              f'be between 0 and {len(UpperCAmelCase      ) - 1}.'      )
     if cryptomath.gcd(UpperCAmelCase		,      len(UpperCAmelCase      )      ) != 1:
          sys.exit(
              f'Key A {key_a} and the symbol set size {len(UpperCAmelCase      )} '
              'are not relatively prime. Choose a different key.'      )







def       UpperCAmelCase					(	UpperCAmelCase		,      UpperCAmelCase      )       ->   str:
     snake_case_ ,			snake_case_       =      divmod(UpperCAmelCase		,      len(UpperCAmelCase      )      )
     check_keys(UpperCAmelCase		,      UpperCAmelCase		,      'encrypt'      )
     snake_case_       =      ''
     for symbol in message:
          if symbol in SYMBOLS:
               snake_case_       =      SYMBOLS.find(UpperCAmelCase      )
               cipher_text += SYMBOLS[(sym_index * key_a + key_b) % len(UpperCAmelCase      )]
          else:
               cipher_text += symbol
     return cipher_text







def       UpperCAmelCase					(	UpperCAmelCase		,      UpperCAmelCase      )       ->   str:
     snake_case_ ,			snake_case_       =      divmod(UpperCAmelCase		,      len(UpperCAmelCase      )      )
     check_keys(UpperCAmelCase		,      UpperCAmelCase		,      'decrypt'      )
     snake_case_       =      ''
     snake_case_       =      cryptomath.find_mod_inverse(UpperCAmelCase		,      len(UpperCAmelCase      )      )
     for symbol in message:
          if symbol in SYMBOLS:
               snake_case_       =      SYMBOLS.find(UpperCAmelCase      )
               plain_text += SYMBOLS[
                   (sym_index - key_b) * mod_inverse_of_key_a % len(UpperCAmelCase      )
               ]
          else:
               plain_text += symbol
     return plain_text







def       UpperCAmelCase					(	)       ->   int:
     while True:
          snake_case_       =      random.randint(2		,      len(UpperCAmelCase      )      )
          snake_case_       =      random.randint(2		,      len(UpperCAmelCase      )      )
          if cryptomath.gcd(UpperCAmelCase		,      len(UpperCAmelCase      )      ) == 1 and key_b % len(UpperCAmelCase      ) != 0:
               return key_b * len(UpperCAmelCase      ) + key_b







def       UpperCAmelCase					(	)       ->   None:
     snake_case_       =      input('Enter message: '      ).strip()
     snake_case_       =      int(input('Enter key [2000 - 9000]: '      ).strip()      )
     snake_case_       =      input('Encrypt/Decrypt [E/D]: '      ).strip().lower()

     if mode.startswith('e'      ):
          snake_case_       =      'encrypt'
          snake_case_       =      encrypt_message(UpperCAmelCase		,      UpperCAmelCase      )
     elif mode.startswith('d'      ):
          snake_case_       =      'decrypt'
          snake_case_       =      decrypt_message(UpperCAmelCase		,      UpperCAmelCase      )
     print(f'\n{mode.title()}ed text: \n{translated}'      )


if __name__ == "__main__":
    import doctest

    doctest.testmod()
    # main()

