

import random
import sys

lowerCamelCase   					=  '''ABCDEFGHIJKLMNOPQRSTUVWXYZ'''


def 							__lowercase     (	):

					"""simple docstring"""






					__lowerCAmelCase       =				input('Enter message: '   )
					__lowerCAmelCase       =				"""LFWOAYUISVKMNXPBDCRJTQEGHZ"""
					__lowerCAmelCase       =				input('Encrypt/Decrypt [e/d]: '   )

					check_valid_key(__SCREAMING_SNAKE_CASE   )

					if resp.lower().startswith('e'   ):
										__lowerCAmelCase       =				"""encrypt"""
										__lowerCAmelCase       =				encrypt_message(__SCREAMING_SNAKE_CASE		,       __SCREAMING_SNAKE_CASE   )
					elif resp.lower().startswith('d'   ):
										__lowerCAmelCase       =				"""decrypt"""
										__lowerCAmelCase       =				decrypt_message(__SCREAMING_SNAKE_CASE		,       __SCREAMING_SNAKE_CASE   )

					print(F"""\n{mode.title()}ion: \n{translated}"""   )


def 							__lowercase     (	UpperCAmelCase__   ):

					"""simple docstring"""






					__lowerCAmelCase       =				list(__SCREAMING_SNAKE_CASE   )
					__lowerCAmelCase       =				list(__SCREAMING_SNAKE_CASE   )
					key_list.sort()
					letters_list.sort()

					if key_list != letters_list:
										sys.exit('Error in the key or symbol set.'   )


def 							__lowercase     (	UpperCAmelCase__		,       UpperCAmelCase__   ):

					"""simple docstring"""






					return translate_message(__SCREAMING_SNAKE_CASE		,       __SCREAMING_SNAKE_CASE		,       'encrypt'   )


def 							__lowercase     (	UpperCAmelCase__		,       UpperCAmelCase__   ):

					"""simple docstring"""






					return translate_message(__SCREAMING_SNAKE_CASE		,       __SCREAMING_SNAKE_CASE		,       'decrypt'   )


def 							__lowercase     (	UpperCAmelCase__		,       UpperCAmelCase__		,       UpperCAmelCase__   ):

					"""simple docstring"""






					__lowerCAmelCase       =				""""""
					__lowerCAmelCase       =				LETTERS
					__lowerCAmelCase       =				key

					if mode == "decrypt":
										__lowerCAmelCase       =				chars_b, chars_a

					for symbol in message:
										if symbol.upper() in chars_a:
															__lowerCAmelCase       =				chars_a.find(symbol.upper()   )
															if symbol.isupper():
																				translated += chars_b[sym_index].upper()
															else:
																				translated += chars_b[sym_index].lower()
										else:
															translated += symbol

					return translated


def 							__lowercase     (	):

					"""simple docstring"""






					__lowerCAmelCase       =				list(__SCREAMING_SNAKE_CASE   )
					random.shuffle(__SCREAMING_SNAKE_CASE   )
					return "".join(__SCREAMING_SNAKE_CASE   )


if __name__ == "__main__":
		main()







import math
from timeit import timeit







def 					__lowerCAmelCase				(		__SCREAMING_SNAKE_CASE       :					int   ):







    '''simple docstring'''
    __snake_case       :				Optional[Any] 			=    0
    __snake_case       :				Union[str, Any] 			=    abs(__SCREAMING_SNAKE_CASE   )
    while True:
        __snake_case       :				List[str] 			=    n // 1_0
        digits += 1
        if n == 0:
            break
    return digits







def 					__lowerCAmelCase				(		__SCREAMING_SNAKE_CASE       :					int   ):







    '''simple docstring'''
    return 1 if n == 0 else math.floor(math.log(abs(__SCREAMING_SNAKE_CASE   )		,							1_0   ) + 1   )







def 					__lowerCAmelCase				(		__SCREAMING_SNAKE_CASE       :					int   ):







    '''simple docstring'''
    return len(str(abs(__SCREAMING_SNAKE_CASE   )   )   )







def 					__lowerCAmelCase				(		):







    '''simple docstring'''
    from collections.abc import Callable

    def benchmark_a_function(__SCREAMING_SNAKE_CASE       :					Callable		,							__SCREAMING_SNAKE_CASE       :					int   ) -> None:
        __snake_case       :				Tuple 			=    F'''{func.__name__}({value})'''
        __snake_case       :				Union[str, Any] 			=    timeit(F'''__main__.{call}'''		,							setup="""import __main__"""   )
        print(F'''{call}: {func(__SCREAMING_SNAKE_CASE   )} -- {timing} seconds'''   )

    for value in (2_6_2_1_4_4, 1_1_2_5_8_9_9_9_0_6_8_4_2_6_2_4, 1_2_6_7_6_5_0_6_0_0_2_2_8_2_2_9_4_0_1_4_9_6_7_0_3_2_0_5_3_7_6):
        for func in (num_digits, num_digits_fast, num_digits_faster):
            benchmark_a_function(__SCREAMING_SNAKE_CASE		,							__SCREAMING_SNAKE_CASE   )
        print()


if __name__ == "__main__":
     import doctest

     doctest.testmod()
     benchmark()



