





"""simple docstring"""


class    lowercase_ :

       def __init__(	self      ,    __SCREAMING_SNAKE_CASE=None   ):






        '''simple docstring'''

        snake_case__										= data
        snake_case__										= None

       def __repr__(	self   ):






        '''simple docstring'''

        snake_case__										= ""
        snake_case__										= self
        while temp:
         string_rep += F"<{temp.data}> ---> "
         snake_case__										= temp.next
        string_rep += "<END>"
        return string_rep





def 							a__	(     _UpperCAmelCase		)			->     Tuple:

 '''simple docstring'''






 if not elements_list:
  raise Exception("The Elements List is empty"		)

 # Set first element as Head
 snake_case__										= Node(elements_list[0]		)
 snake_case__										= head
 # Loop through elements from position 1
 for data in elements_list[1:]:
  snake_case__										= Node(_UpperCAmelCase		)
  snake_case__										= current.next
 return head


a__    :   List[Any]    						= [1, 3, 5, 3_2, 4_4, 1_2, 4_3]
print(f'''List: {list_data}''')
print("""Creating Linked List from List.""")
a__    :   Any    						= make_linked_list(list_data)
print("""Linked List:""")

print(linked_list)








"""simple docstring"""


import random
import sys

from . import cryptomath_module as cryptomath

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





def 							a__	(     _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 							a__	(     _UpperCAmelCase		,   _UpperCAmelCase		)			->     str:

 '''simple docstring'''






 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 							a__	(     _UpperCAmelCase		,   _UpperCAmelCase		)			->     str:

 '''simple docstring'''






 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 							a__	(     )			->     int:

 '''simple docstring'''






 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 							a__	(     )			->     None:

 '''simple docstring'''






 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()

