





import re

from filelock import FileLock


try:
					import nltk

					UpperCamelCase__											= True
except (ImportError, ModuleNotFoundError):
					UpperCamelCase__											= False

if NLTK_AVAILABLE:
					with FileLock(".lock") as lock:
										nltk.download("punkt", quiet=True)





def     _UpperCamelCase     (a__   :str       ):






							"""simple docstring"""





							re.sub("""<n>"""   ,			""""""   ,			a__       )  # remove pegasus newline char
							assert NLTK_AVAILABLE, "nltk must be installed to separate newlines between sentences. (pip install nltk)"
							return "\n".join(nltk.sent_tokenize(a__       )       )











UpperCamelCase__											= "ABCDEFGHIJKLMNOPQRSTUVWXYZ"





def     _UpperCamelCase     ():






							"""simple docstring"""





							UpperCamelCase__				     =			input("""Enter message: """       )
							UpperCamelCase__				     =			input("""Enter key [alphanumeric]: """       )
							UpperCamelCase__				     =			input("""Encrypt/Decrypt [e/d]: """       )

							if mode.lower().startswith("""e"""       ):
														UpperCamelCase__				     =			"""encrypt"""
														UpperCamelCase__				     =			encrypt_message(a__   ,			a__       )
							elif mode.lower().startswith("""d"""       ):
														UpperCamelCase__				     =			"""decrypt"""
														UpperCamelCase__				     =			decrypt_message(a__   ,			a__       )

							print(f"""\n{mode.title()}ed message:"""       )
							print(a__       )





def     _UpperCamelCase     (a__   :str   ,			a__   :str       ):






							"""simple docstring"""





							return translate_message(a__   ,			a__   ,			"""encrypt"""       )





def     _UpperCamelCase     (a__   :str   ,			a__   :str       ):






							"""simple docstring"""





							return translate_message(a__   ,			a__   ,			"""decrypt"""       )





def     _UpperCamelCase     (a__   :str   ,			a__   :str   ,			a__   :str       ):






							"""simple docstring"""





							UpperCamelCase__				     =			[]
							UpperCamelCase__				     =			0
							UpperCamelCase__				     =			key.upper()

							for symbol in message:
														UpperCamelCase__				     =			LETTERS.find(symbol.upper()       )
														if num != -1:
																					if mode == "encrypt":
																												num += LETTERS.find(key[key_index]       )
																					elif mode == "decrypt":
																												num -= LETTERS.find(key[key_index]       )

																					num %= len(a__       )

																					if symbol.isupper():
																												translated.append(LETTERS[num]       )
																					elif symbol.islower():
																												translated.append(LETTERS[num].lower()       )

																					key_index += 1
																					if key_index == len(a__       ):
																												UpperCamelCase__				     =			0
														else:
																					translated.append(a__       )
							return "".join(a__       )


if __name__ == "__main__":
					main()




