






import os
import random
import sys

from . import cryptomath_module as cryptoMath  # noqa: N812
from . import rabin_miller as rabinMiller  # noqa: N812





def 		__UpperCAmelCase     (	):
							print('Making key files...')
							make_key_files('rsa'				,	10_24)
							print('Key files generation successful.')





def 		__UpperCAmelCase     (	a_):
							print('Generating prime p...')
							snake_case_           =				rabinMiller.generate_large_prime(a_)
							print('Generating prime q...')
							snake_case_           =				rabinMiller.generate_large_prime(a_)
							snake_case_           =				p * q

							print('Generating e that is relatively prime to (p - 1) * (q - 1)...')
							while True:
														snake_case_           =				random.randrange(2 ** (key_size - 1)				,	2 ** (key_size))
														if cryptoMath.gcd(a_				,	(p - 1) * (q - 1)) == 1:
																					break

							print('Calculating d that is mod inverse of e...')
							snake_case_           =				cryptoMath.find_mod_inverse(a_				,	(p - 1) * (q - 1))

							snake_case_           =				(n, e)
							snake_case_           =				(n, d)
							return (public_key, private_key)





def 		__UpperCAmelCase     (	a_				,	a_):
							if os.path.exists(f'''{name}_pubkey.txt''') or os.path.exists(f'''{name}_privkey.txt'''):
														print('\nWARNING:')
														print(
														    f'''"{name}_pubkey.txt" or "{name}_privkey.txt" already exists. \n'''
														    'Use a different name or delete these files and re-run this program.')
														sys.exit()

							snake_case_     ,						snake_case_           =				generate_key(a_)
							print(f'''\nWriting public key to file {name}_pubkey.txt...''')
							with open(f'''{name}_pubkey.txt'''				,	'w') as out_file:
														out_file.write(f'''{key_size},{public_key[0]},{public_key[1]}''')

							print(f'''Writing private key to file {name}_privkey.txt...''')
							with open(f'''{name}_privkey.txt'''				,	'w') as out_file:
														out_file.write(f'''{key_size},{private_key[0]},{private_key[1]}''')


if __name__ == "__main__":
	main()













lowercase    				=   {
    "A": ".-", "B": "-...", "C": "-.-.", "D": "-..", "E": ".", "F": "..-.", "G": "--.",
    "H": "....", "I": "..", "J": ".---", "K": "-.-", "L": ".-..", "M": "--", "N": "-.",
    "O": "---", "P": ".--.", "Q": "--.-", "R": ".-.", "S": "...", "T": "-", "U": "..-",
    "V": "...-", "W": ".--", "X": "-..-", "Y": "-.--", "Z": "--..", "1": ".----",
    "2": "..---", "3": "...--", "4": "....-", "5": ".....", "6": "-....", "7": "--...",
    "8": "---..", "9": "----.", "0": "-----", "&": ".-...", "@": ".--.-.",
    ":": "---...", ",": "--..--", ".": ".-.-.-", "'": ".----.", "\"": ".-..-.",
    "?": "..--..", "/": "-..-.", "=": "-...-", "+": ".-.-.", "-": "-....-",
    "(": "-.--.", ")": "-.--.-", "!": "-.-.--", " ": "/"
}  # Exclamation mark is not in ITU-R recommendation
# fmt: on
lowercase    				=   {value: key for key, value in MORSE_CODE_DICT.items()}





def 		__UpperCAmelCase     (	a_):
							return " ".join(MORSE_CODE_DICT[char] for char in message.upper())





def 		__UpperCAmelCase     (	a_):
							return "".join(REVERSE_DICT[char] for char in message.split())





def 		__UpperCAmelCase     (	):
							snake_case_           =				'Morse code here!'
							print(a_)
							snake_case_           =				encrypt(a_)
							print(a_)
							snake_case_           =				decrypt(a_)
							print(a_)


if __name__ == "__main__":
	main()





