import secrets
import pyAesCrypt
from simple_term_menu import TerminalMenu
#Sources : https://github.com/marcobellaccini/pyAesCrypt
# https://docs.python.org/3/library/secrets.html
def encrypt(filename):
with open('dict/dict.txt') as f:
words = [word.strip() for word in f]
password = ' '.join(secrets.choice(words) for i in range(8))
print(f"Here's your securely generated passphrase >> {password}")
# encrypt
pyAesCrypt.encryptFile(filename, f"output/{filename}.aes", password)
def decrypt(filename,password):
# decrypt
pyAesCrypt.decryptFile(f"{filename}", "output/dataout.txt", password)
def main():
options = ["Encrypt", "Decrypt"]
terminal_menu = TerminalMenu(options)
menu_entry_index = terminal_menu.show()
if options[menu_entry_index] == "Encrypt":
encrypt(input(str('Filename ? >>')))
elif options[menu_entry_index] == "Decrypt":
decrypt(input(str('Filename ? >> ')),input(str('Password ? >> ')))
if __name__ == "__main__":
main()