

def     __magic_name__       ( A					,   A							)			->		str:






	if not isinstance(UpperCAmelCase_					,   UpperCAmelCase_							):
		raise TypeError('plaintext must be a string'							)
	if not isinstance(UpperCAmelCase_					,   UpperCAmelCase_							):
		raise TypeError('key must be a string'							)

	if not plaintext:
		raise ValueError('plaintext is empty'							)
	if not key:
		raise ValueError('key is empty'							)

	key += plaintext
	snake_case							 =				plaintext.lower()
	snake_case							 =				key.lower()
	snake_case							 =				0
	snake_case							 =				0
	snake_case							 =				''''''
	while plaintext_iterator < len(UpperCAmelCase_							):
		if (
		    ord(plaintext[plaintext_iterator]							) < 9_7
		    or ord(plaintext[plaintext_iterator]							) > 1_2_2
		):
			ciphertext += plaintext[plaintext_iterator]
			plaintext_iterator += 1
		elif ord(key[key_iterator]							) < 9_7 or ord(key[key_iterator]							) > 1_2_2:
			key_iterator += 1
		else:
			ciphertext += chr(
			    (
			        (ord(plaintext[plaintext_iterator]							) - 9_7 + ord(key[key_iterator]							))
			        - 9_7
			    )
			    % 2_6
			    + 9_7							)
			key_iterator += 1
			plaintext_iterator += 1
	return ciphertext

def     __magic_name__       ( A					,   A							)			->		str:






	if not isinstance(UpperCAmelCase_					,   UpperCAmelCase_							):
		raise TypeError('ciphertext must be a string'							)
	if not isinstance(UpperCAmelCase_					,   UpperCAmelCase_							):
		raise TypeError('key must be a string'							)

	if not ciphertext:
		raise ValueError('ciphertext is empty'							)
	if not key:
		raise ValueError('key is empty'							)

	snake_case							 =				key.lower()
	snake_case							 =				0
	snake_case							 =				0
	snake_case							 =				''''''
	while ciphertext_iterator < len(UpperCAmelCase_							):
		if (
		    ord(ciphertext[ciphertext_iterator]							) < 9_7
		    or ord(ciphertext[ciphertext_iterator]							) > 1_2_2
		):
			plaintext += ciphertext[ciphertext_iterator]
		else:
			plaintext += chr(
			    (ord(ciphertext[ciphertext_iterator]							) - ord(key[key_iterator]							)) % 2_6
			    + 9_7							)
			key += chr(
			    (ord(ciphertext[ciphertext_iterator]							) - ord(key[key_iterator]							)) % 2_6
			    + 9_7							)
			key_iterator += 1
		ciphertext_iterator += 1
	return plaintext


if __name__ == "__main__":
						import doctest

						doctest.testmod()
						lowerCAmelCase_						   =			int(input("Type 1 to encrypt or 2 to decrypt:"))
						if operation == 1:
												lowerCAmelCase_						   =			input("Typeplaintext to be encrypted:\n")
												lowerCAmelCase_						   =			input("Type the key:\n")
												print(encrypt(plaintext, key))
						elif operation == 2:
												lowerCAmelCase_						   =			input("Type the ciphertext to be decrypted:\n")
												lowerCAmelCase_						   =			input("Type the key:\n")
												print(decrypt(ciphertext, key))
						decrypt("jsqqs avvwo", "coffee")








'''simple docstring'''

from cva import destroyAllWindows, imread, imshow, waitKey

def     __magic_name__       ( A					,   A							)			->		Union[str, Any]:
	snake_case , snake_case							 =				img.shape[0], img.shape[1]

	def to_grayscale(A					,   A					,   A							):
		return 0.2_126 * red + 0.587 * green + 0.114 * blue

	def normalize(A							):
		return min(A					,   2_5_5							)

	for i in range(A							):
		for j in range(A							):
			snake_case							 =				int(to_grayscale(*img[i][j]							)							)
			snake_case							 =				[
			    normalize(A							),
			    normalize(greyscale + factor							),
			    normalize(greyscale + 2 * factor							),
			]

	return img


if __name__ == "__main__":
						# read original image
						lowerCAmelCase_						   =			{
						    percentage: imread("image_data/lena.jpg", 1) for percentage in (1_0, 2_0, 3_0, 4_0)
						}

						for percentage, img in images.items():
												make_sepia(img, percentage)

						for percentage, img in images.items():
												imshow(f"Original image with sepia (factor: {percentage})", img)

						waitKey(0)
						destroyAllWindows()





