




"""simple docstring"""





from typing import Literal

_lowercase		 =      """ABCDEFGHIJKLMNOPQRSTUVWXYZ"""



def 						lowerCAmelCase							(	lowerCamelCase ,     lowerCamelCase ,     lowerCamelCase						):
						'''simple docstring'''


						snake_case__    :   Optional[Any]							     =   LETTERS if mode == '''decrypt''' else key
						snake_case__    :   str							     =   key if mode == '''decrypt''' else LETTERS
						snake_case__    :   Any							     =   ''''''
						# loop through each symbol in the message
						for symbol in message:
												if symbol.upper() in chars_a:
																		# encrypt/decrypt the symbol
																		snake_case__    :   Optional[Any]							     =   chars_a.find(symbol.upper()						)
																		if symbol.isupper():
																								translated += chars_b[sym_index].upper()
																		else:
																								translated += chars_b[sym_index].lower()
												else:
																		# symbol is not in LETTERS, just add it
																		translated += symbol
						return translated



def 						lowerCAmelCase							(	lowerCamelCase ,     lowerCamelCase						):
						'''simple docstring'''


						return translate_message(lowerCamelCase ,     lowerCamelCase ,     '''encrypt'''						)



def 						lowerCAmelCase							(	lowerCamelCase ,     lowerCamelCase						):
						'''simple docstring'''


						return translate_message(lowerCamelCase ,     lowerCamelCase ,     '''decrypt'''						)



def 						lowerCAmelCase							(	):
						'''simple docstring'''


						snake_case__    :   Optional[Any]							     =   '''Hello World'''
						snake_case__    :   List[str]							     =   '''QWERTYUIOPASDFGHJKLZXCVBNM'''
						snake_case__    :   List[str]							     =   '''decrypt'''  # set to 'encrypt' or 'decrypt'

						if mode == "encrypt":
												snake_case__    :   str							     =   encrypt_message(lowerCamelCase ,     lowerCamelCase						)
						elif mode == "decrypt":
												snake_case__    :   List[str]							     =   decrypt_message(lowerCamelCase ,     lowerCamelCase						)
						print(f'''Using the key {key}, the {mode}ed message is: {translated}'''						)


if __name__ == "__main__":
							import doctest

							doctest.testmod()
							main()








"""simple docstring"""





from __future__ import annotations

import math
import random

def 						lowerCAmelCase							(	lowerCamelCase ,     lowerCamelCase ,     lowerCamelCase						):
						'''simple docstring'''


						snake_case__    :   Tuple							     =   d * e - 1
						snake_case__    :   Optional[int]							     =   0
						snake_case__    :   Tuple							     =   0
						while p == 0:
												snake_case__    :   Optional[int]							     =   random.randint(2 ,     n - 1						)
												snake_case__    :   Tuple							     =   k
												while True:
																		if t % 2 == 0:
																								snake_case__    :   List[Any]							     =   t // 2
																								snake_case__    :   Union[str, Any]							     =   (g**t) % n
																								snake_case__    :   Dict							     =   math.gcd(x - 1 ,     lowerCamelCase						)
																								if x > 1 and y > 1:
																														snake_case__    :   Union[str, Any]							     =   y
																														snake_case__    :   str							     =   n // y
																														break  # find the correct factors
																		else:
																								break  # t is not divisible by 2, break and choose another g
						return sorted([p, q]						)


if __name__ == "__main__":
							import doctest

							doctest.testmod()


