



import os
import sys
import time

from . import transposition_cipher as trans_cipher

def 	a						(				):







		'''simple docstring'''





		__UpperCAmelCase   :					Union[str, Any]													=     '''Prehistoric Men.txt'''
		__UpperCAmelCase   :					Union[str, Any]													=     '''Output.txt'''
		__UpperCAmelCase   :					List[Any]													=     int(input('''Enter key: '''						)						)
		__UpperCAmelCase   :					Optional[int]													=     input('''Encrypt/Decrypt [e/d]: '''						)

		if not os.path.exists(_UpperCAmelCase						):
				print(f'File {input_file} does not exist. Quitting...'						)
				sys.exit()
		if os.path.exists(_UpperCAmelCase						):
				print(f'Overwrite {output_file}? [y/n]'						)
				__UpperCAmelCase   :					Any													=     input('''> '''						)
				if not response.lower().startswith('''y'''						):
						sys.exit()

		__UpperCAmelCase   :					List[Any]													=     time.time()
		if mode.lower().startswith('''e'''						):
				with open(_UpperCAmelCase						) as f:
						__UpperCAmelCase   :					str													=     f.read()
				__UpperCAmelCase   :					List[str]													=     trans_cipher.encrypt_message(_UpperCAmelCase			,       _UpperCAmelCase						)
		elif mode.lower().startswith('''d'''						):
				with open(_UpperCAmelCase						) as f:
						__UpperCAmelCase   :					str													=     f.read()
				__UpperCAmelCase   :					Any													=     trans_cipher.decrypt_message(_UpperCAmelCase			,       _UpperCAmelCase						)

		with open(_UpperCAmelCase			,       '''w'''						) as output_obj:
				output_obj.write(_UpperCAmelCase						)

		__UpperCAmelCase   :					Dict													=     round(time.time() - start_time			,       2						)
		print(('''Done (''', total_time, '''seconds )''')						)


if __name__ == "__main__":
				main()








def 	a						(				_UpperCAmelCase							: str						):







		'''simple docstring'''





		__UpperCAmelCase   :					Optional[Any]													=     53_81
		for x in s:
				__UpperCAmelCase   :					str													=     ((hash_value << 5) + hash_value) + ord(_UpperCAmelCase						)
		return hash_value & 0xFFFF_FFFF





