code: 
  
  
  import random
  import sys
  
  from . import cryptomath_module as cryptomath
  
  __a   				=      (
      r''' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`'''
      r'''abcdefghijklmnopqrstuvwxyz{|}~'''
  )
  
  
  
  
  def 			__lowercase	(						_UpperCamelCase,    _UpperCamelCase,    _UpperCamelCase     )    ->None:
  
  
  
  
  
  
  
        """simple docstring"""
  
        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 			__lowercase	(						_UpperCamelCase,    _UpperCamelCase     )    ->str:
  
  
  
  
  
  
  
        """simple docstring"""
  
        lowercase   ,			lowercase			:   List[str]					   =		divmod(_UpperCamelCase,    len(_UpperCamelCase     )     )
        check_keys(_UpperCamelCase,    _UpperCamelCase,    '''encrypt'''     )
        lowercase			:   List[Any]					   =		''''''
        for symbol in message:
              if symbol in SYMBOLS:
                    lowercase			:   Optional[int]					   =		SYMBOLS.find(_UpperCamelCase     )
                    cipher_text += SYMBOLS[(sym_index * key_a + key_b) % len(_UpperCamelCase     )]
              else:
                    cipher_text += symbol
        return cipher_text
  
  
  
  
  def 			__lowercase	(						_UpperCamelCase,    _UpperCamelCase     )    ->str:
  
  
  
  
  
  
  
        """simple docstring"""
  
        lowercase   ,			lowercase			:   List[str]					   =		divmod(_UpperCamelCase,    len(_UpperCamelCase     )     )
        check_keys(_UpperCamelCase,    _UpperCamelCase,    '''decrypt'''     )
        lowercase			:   List[str]					   =		''''''
        lowercase			:   Dict					   =		cryptomath.find_mod_inverse(_UpperCamelCase,    len(_UpperCamelCase     )     )
        for symbol in message:
              if symbol in SYMBOLS:
                    lowercase			:   Any					   =		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 			__lowercase	(						)    ->int:
  
  
  
  
  
  
  
        """simple docstring"""
  
        while True:
              lowercase			:   Optional[int]					   =		random.randint(2,    len(_UpperCamelCase     )     )
              lowercase			:   Tuple					   =		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 			__lowercase	(						)    ->None:
  
  
  
  
  
  
  
        """simple docstring"""
  
        lowercase			:   List[str]					   =		input('''Enter message: '''     ).strip()
        lowercase			:   Optional[int]					   =		int(input('''Enter key [2000 - 9000]: '''     ).strip()     )
        lowercase			:   Optional[Any]					   =		input('''Encrypt/Decrypt [E/D]: '''     ).strip().lower()
  
        if mode.startswith('''e'''     ):
              lowercase			:   str					   =		'''encrypt'''
              lowercase			:   int					   =		encrypt_message(_UpperCamelCase,    _UpperCamelCase     )
        elif mode.startswith('''d'''     ):
              lowercase			:   str					   =		'''decrypt'''
              lowercase			:   Dict					   =		decrypt_message(_UpperCamelCase,    _UpperCamelCase     )
        print(f"""\n{mode.title()}ed text: \n{translated}"""     )
  
  
  if __name__ == "__main__":
    import doctest
  
    doctest.testmod()
    # main()
  
  
style_context: 
  
  
  from __future__ import annotations
  
  
  
  
  def 			__lowercase	(						_UpperCamelCase     )    ->list[int]:
  
  
  
  
  
  
  
        """simple docstring"""
  
        assert (
            isinstance(_UpperCamelCase,    _UpperCamelCase     ) and mask > 0
        ), f"""mask needs to be positive integer, your input {mask}"""
        lowercase			:   Optional[int]					   =		[]
        lowercase			:   Optional[int]					   =		mask
  
        while submask:
              all_submasks.append(_UpperCamelCase     )
              lowercase			:   Dict					   =		(submask - 1) & mask
  
        return all_submasks
  
  
  if __name__ == "__main__":
    import doctest
  
    doctest.testmod()
  
  