




'''simple docstring'''






from __future__ import annotations

from string import ascii_letters

def       _lowerCAmelCase (   snake_case__ ,				snake_case__ ,				snake_case__ = None						):
			__UpperCamelCase				:      str									=       alphabet or ascii_letters

			# The final result string
			__UpperCamelCase				:      str									=       ""

			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
									__UpperCamelCase				:      Dict									=       (alpha.index(A_						) + key) % len(A_						)

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

			return result

def       _lowerCAmelCase (   snake_case__ ,				snake_case__ ,				snake_case__ = None						):
			key *= -1

			return encrypt(A_ ,				A_ ,				A_						)

def       _lowerCAmelCase (   snake_case__ ,				snake_case__ = None						):
			__UpperCamelCase				:      Tuple									=       alphabet or ascii_letters

			# To store data on all the combinations
			__UpperCamelCase				:      Optional[int]									=       {}

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

			return brute_force_data


if __name__ == "__main__":
				while True:
								print(f'\n{"-" * 10}\n Menu\n{"-" * 10}')
								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









'''simple docstring'''






import math
import os

import cva
import numpy as np

_lowerCAmelCase				     = 255.0

def       __lowerCAmelCase (   snake_case__ ,				snake_case__						):
			__UpperCamelCase				:      Dict									=       np.mean((original - contrast) ** 2						)
			if mse == 0:
						return 100

			return 20 * math.logaa(PIXEL_MAX / math.sqrt(snake_case__						)						)

def       __lowerCAmelCase (   ):
			__UpperCamelCase				:      Tuple									=       os.path.dirname(os.path.realpath(snake_case__						)						)
			# Loading images (original image and compressed image)
			__UpperCamelCase				:      Tuple									=       cva.imread(os.path.join(snake_case__ ,				"image_data/original_image.png"						)						)
			__UpperCamelCase				:      List[Any]									=       cva.imread(os.path.join(snake_case__ ,				"image_data/compressed_image.png"						) ,				1						)

			__UpperCamelCase				:      Dict									=       cva.imread(os.path.join(snake_case__ ,				"image_data/PSNR-example-base.png"						)						)
			__UpperCamelCase				:      Optional[Any]									=       cva.imread(
			    os.path.join(snake_case__ ,				"image_data/PSNR-example-comp-10.jpg"						) ,				1						)

			# Value expected: 29.73dB
			print("-- First Test --"						)
			print(F"PSNR value is {peak_signal_to_noise_ratio(snake_case__ ,				snake_case__						)} dB"						)

			# # Value expected: 31.53dB (Wikipedia Example)
			print("\n-- Second Test --"						)
			print(F"PSNR value is {peak_signal_to_noise_ratio(snake_case__ ,				snake_case__						)} dB"						)


if __name__ == "__main__":
				main()



