






import timeit




class 							a_				:


							'''simple docstring'''






							def __init__(	self    ,    lowercase_     )      ->      List[str]:
														'''simple docstring'''

														if isinstance(lowercase_    ,    lowercase_     ):  # Initializes a matrix identical to the one provided.
																					lowerCAmelCase_       		=  arg
																					lowerCAmelCase_       		=  len(lowercase_     )
														else:  # Initializes a square matrix of the given size and set values to zero.
																					lowerCAmelCase_       		=  arg
																					lowerCAmelCase_       		=  [[0 for _ in range(self.n     )] for _ in range(self.n     )]






							def __mul__(	self    ,    lowercase_     )      ->      Optional[int]:
														'''simple docstring'''

														lowerCAmelCase_       		=  Matrix(self.n     )
														for i in range(self.n     ):
																					for j in range(self.n     ):
																												for k in range(self.n     ):
																																			matrix.t[i][j] += self.t[i][k] * b.t[k][j]
														return matrix


def   lowerCamelCase      (		a_				,		a_			)			->    str:
							lowerCAmelCase_       		=  Matrix([[1, 0], [0, 1]]			)
							while b > 0:
														if b & 1:
																					matrix *= a
														a *= a
														b >>= 1
							return matrix
def   lowerCamelCase      (		a_				,		a_				,		a_			)			->    Optional[Any]:
							# Trivial Cases
							if n == 1:
														return fa
							elif n == 2:
														return fa
							lowerCAmelCase_       		=  Matrix([[1, 1], [1, 0]]			)
							lowerCAmelCase_       		=  modular_exponentiation(a_				,		n - 2			)
							return fa * matrix.t[0][0] + fa * matrix.t[0][1]
def   lowerCamelCase      (		a_				,		a_				,		a_			)			->    Optional[Any]:
							# Trivial Cases
							if n == 1:
														return fa
							elif n == 2:
														return fa

							lowerCAmelCase_       		=  fa
							lowerCAmelCase_       		=  fa
							n -= 2

							while n > 0:
														lowerCAmelCase_		,     lowerCAmelCase_       		=  fn_a + fn_a, fn_a
														n -= 1

							return fn_a
def   lowerCamelCase      (		)			->    Tuple:
							lowerCAmelCase_       		=  '\nfrom random import randint\nfrom __main__ import fibonacci_with_matrix_exponentiation\n'
							lowerCAmelCase_       		=  'fibonacci_with_matrix_exponentiation(randint(1,70000), 1, 1)'
							lowerCAmelCase_       		=  timeit.timeit(setup=a_				,		stmt=a_				,		number=100			)
							print('With matrix exponentiation the average execution time is '				,		exec_time / 100			)
							return exec_time
def   lowerCamelCase      (		)			->    int:
							lowerCAmelCase_       		=  '\nfrom random import randint\nfrom __main__ import simple_fibonacci\n'
							lowerCAmelCase_       		=  'simple_fibonacci(randint(1,70000), 1, 1)'
							lowerCAmelCase_       		=  timeit.timeit(setup=a_				,		stmt=a_				,		number=100			)
							print(
							    'Without matrix exponentiation the average execution time is '				,		exec_time / 100			)
							return exec_time
def   lowerCamelCase      (		)			->    List[str]:
							matrix_exponentiation_time()
							simple_fibonacci_time()


if __name__ == "__main__":
		main()











from __future__ import annotations

from string import ascii_letters
def   lowerCamelCase      (		a_				,		a_				,		a_ = None			)			->    str:
							lowerCAmelCase_       		=  alphabet or ascii_letters

							# The final result string
							lowerCAmelCase_       		=  ''

							for character in input_string:
														if character not in alpha:
																					# Append without encryption if character is not in the alphabet
																					result += character
														else:
																					# Get the index of the new key and make sure it isn't too large
																					lowerCAmelCase_       		=  (alpha.index(a_			) + key) % len(a_			)

																					# Append the encoded character to the alphabet
																					result += alpha[new_key]

							return result
def   lowerCamelCase      (		a_				,		a_				,		a_ = None			)			->    str:
							key *= -1

							return encrypt(a_				,		a_				,		a_			)
def   lowerCamelCase      (		a_				,		a_ = None			)			->    dict[int, str]:
							lowerCAmelCase_       		=  alphabet or ascii_letters

							# To store data on all the combinations
							lowerCAmelCase_       		=  {}

							# Cycle through each combination
							for key in range(1				,		len(a_			) + 1			):
														# Decrypt the message and store the result in the data
														lowerCAmelCase_       		=  decrypt(a_				,		a_				,		a_			)

							return brute_force_data


if __name__ == "__main__":
		while True:
				print(f'''\n{"-" * 1_0}\n Menu\n{"-" * 1_0}''')
				print(*["""1.Encrypt""", """2.Decrypt""", """3.BruteForce""", """4.Quit"""], sep="""\n""")

				# get user input
				lowerCamelCase_		  =						input("""\nWhat would you like to do?: """).strip() or """4"""

				# run functions based on what the user chose
				if choice not in ("1", "2", "3", "4"):
						print("""Invalid choice, please enter a valid choice""")
				elif choice == "1":
						lowerCamelCase_		  =						input("""Please enter the string to be encrypted: """)
						lowerCamelCase_		  =						int(input("""Please enter off-set: """).strip())

						print(encrypt(input_string, key))
				elif choice == "2":
						lowerCamelCase_		  =						input("""Please enter the string to be decrypted: """)
						lowerCamelCase_		  =						int(input("""Please enter off-set: """).strip())

						print(decrypt(input_string, key))
				elif choice == "3":
						lowerCamelCase_		  =						input("""Please enter the string to be decrypted: """)
						lowerCamelCase_		  =						brute_force(input_string)

						for key, value in brute_force_data.items():
								print(f'''Key: {key} | Message: {value}''')

				elif choice == "4":
						print("""Goodbye.""")
						break



