figenc

[RADIOACTIVE] rsa and symmetric key encryption scripts and executables
git clone git://git.figbert.com/figenc.git
Log | Files | Refs | README

commit 2bb303a5ff0eb0aefa5e83b2aa794113e1a21a1c
parent 1c0d87da23e135322e3c2b35bb94e9e8c42d0c1e
Author: FIGBERT <figbertwelner@gmail.com>
Date:   Mon, 22 Jul 2019 18:48:26 -0700

Adding inital launcher code, enabling image encryption, etc.

Diffstat:
AScripts/app_launcher.py | 58++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
MScripts/encrypt.py | 11++++++++---
MScripts/figENC.py | 942+++++++++++++++++++++++++++++++++++++++++--------------------------------------
AScripts/settings.json | 5+++++
AScripts/tips.json | 13+++++++++++++
5 files changed, 570 insertions(+), 459 deletions(-)

diff --git a/Scripts/app_launcher.py b/Scripts/app_launcher.py @@ -0,0 +1,57 @@ +from random import choice +import time +import threading +from json import load +import tkinter as tk +from tkinter import ttk +from figENC import App + +class Launcher(): + + def __init__(self): + self.root = tk.Tk() + self.root.wm_title("figENC") + self.canvas = tk.Canvas( + self.root, + height=100, + width=450 + ) + self.canvas.pack(fill=tk.BOTH, expand=True) + self.frame = tk.Frame(self.canvas, bg="#1A181C") + self.frame.place(relwidth=1, relheight=1) + self.header = tk.Label( + self.frame, + text="Loading application...", + font=("Arial", "12"), + bg="#1A181C", + fg="#F2DAFF", + pady="5" + ) + self.header.pack(side=tk.TOP) + self.subheader = tk.Label( + self.frame, + text=self.pick_tip(), + font=("Arial", "10"), + bg="#1A181C", + fg="#B494C7" + ) + self.subheader.pack(side=tk.TOP) + self.progressbar = ttk.Progressbar(self.frame, orient="horizontal", length=300, mode="determinate") + self.progressbar.pack(side=tk.TOP) + self.root.mainloop() + + def pick_tip(self): + with open("tips.json") as source: + self.tips = load(source) + self.tip = "Tip: " + choice(self.tips) + return self.tip + + def load(self): + with open("settings.json") as read_file: + self.settings_file = load(read_file) + #Add something that checks the code against this link + #https://github.com/therealFIGBERT/figENC/tree/master/Executables/figENC.app/Contents + App(self.settings_file["font_size"], self.settings_file["scroll"]) + + +Launcher() +\ No newline at end of file diff --git a/Scripts/encrypt.py b/Scripts/encrypt.py @@ -33,9 +33,14 @@ def rsa_enc(target_file_raw, save_folder): symmetric_key_data = symmetric_key_file.read() symmetric_key = Fernet(symmetric_key_data) #Encrypting and outputting the data - with open(target_file) as read_file: - file_data = read_file.read() - data = symmetric_key.encrypt(bytes(file_data, 'utf-8')) + try: + with open(target_file) as read_file: + file_data = read_file.read() + data = symmetric_key.encrypt(bytes(file_data, 'utf-8')) + except UnicodeDecodeError: + with open(target_file, "rb") as read_file: + file_data = read_file.read() + data = symmetric_key.encrypt(file_data) with open(target_file, 'wb') as write_file: write_file.write(data) #Encrypting and outputting the symmetric key diff --git a/Scripts/figENC.py b/Scripts/figENC.py @@ -5,478 +5,508 @@ from encrypt import rsa_enc from decrypt import rsa_dec import check -crypto_mode = "" +class App(): -def reset(): - file_frame.pack_forget() - file_label.pack_forget() - file_instructions.pack_forget() - reset_text(file_input) - file_input.pack_forget() - passcode_frame.pack_forget() - passcode_label.pack_forget() - passcode_instructions.pack_forget() - reset_text(passcode_input) - passcode_input.pack_forget() - confirm_label.pack_forget() - confirm_instructions.pack_forget() - reset_text(confirm_input) - confirm_input.pack_forget() - save.pack_forget() - save_label.pack_forget() - save_instructions.pack_forget() - reset_text(save_input) - save_input.pack_forget() - submit.pack_forget() + def __init__(self, head_font, scroll_bool): + self.crypto_mode = "" - -def setup(mode): - """"Change the GUI to match the app mode, - based on the user's action_list selection. - - Keyword arguments: - mode -- an int (0-6) corresponding with the action_list selection - """ - mode = mode[0] - global crypto_mode - if mode == 0: #Encrypt with fresh keys (password locked) - reset() - file_frame.pack(fill="both") - file_label.config(text="Filepath/s to the file/s to encrypt") - file_label.pack() - file_instructions.pack() - file_input.pack(fill="x") - passcode_frame.pack(fill="both") - passcode_label.config(text="Set private key passcode") - passcode_label.pack() - passcode_instructions.config( - text=( - "CRITICAL: DO NOT FORGET YOUR" - "PASSCODE.\nWITHOUT IT, " - "YOUR DATA WILL BE LOST." - ) + self.root = tk.Tk() + self.root.wm_title("figENC") + self.canvas = tk.Canvas( + self.root, + height=700, + width=700 ) - passcode_instructions.pack() - passcode_input.pack(fill="x") - confirm_label.pack() - confirm_instructions.pack() - confirm_input.pack(fill="x") - save.pack(fill="both") - save_label.config(text="Save location for keys") - save_label.pack() - save_instructions.config( - text=( - "Save the keys to an empty folder, " - "and store them somewhere secure\n" - "If other key files exist in the same" - "folder, they will be overwritten" + if scroll_bool: + self.vertical_scroll = tk.Scrollbar( + self.root, + command=self.canvas.yview ) + self.canvas.config(yscrollcommand=self.vertical_scroll.set) + self.vertical_scroll.pack(side=tk.RIGHT, fill=tk.Y) + self.canvas.pack(fill="both", expand=True, side=tk.LEFT) + self.frame = tk.Frame(self.canvas, bg="#1A181C") + self.frame.place(relwidth=1, relheight=1) + self.header = tk.Label( + self.frame, + text="figENC", + justify=tk.CENTER, + font=("Arial", str(head_font + 6)), + bg="#643181", + fg="#F2DAFF", + pady="2" ) - save_instructions.pack() - save_input.pack(fill="both") - submit.config(text="Encrypt file/s") - submit.pack(pady="10") - crypto_mode = "key_enc" - elif mode == 1: #Encrypt with fresh keys (no password) - reset() - file_frame.pack(fill="both") - file_label.config(text="Filepath/s to the file/s to encrypt") - file_label.pack() - file_instructions.pack() - file_input.pack(fill="x") - save.pack(fill="both") - save_label.config(text="Save location for keys") - save_label.pack() - save_instructions.config( - text=( - "Save the keys to an empty folder, " - "and store them somewhere secure\n" - "If other key files exist in the same" - "folder, they will be overwritten" - ) + self.subheader = tk.Label( + self.frame, + text="Industry leading encryption by FIGBERT", + justify=tk.CENTER, + font=("Arial", str(head_font)), + bg="#643181", + fg="#F2DAFF", + pady="2" ) - save_instructions.pack() - save_input.pack(fill="both") - submit.config(text="Encrypt file/s") - submit.pack(pady="10") - crypto_mode = "weak_key_enc" - elif mode == 2: #Encrypt with generated keys - reset() - file_frame.pack(fill="both") - file_label.config(text="Filepath/s to the file/s to encrypt") - file_label.pack() - file_instructions.pack() - file_input.pack(fill="x") - save.pack(fill="both") - save_label.config(text="Key location") - save_label.pack() - save_instructions.config(text="Filepath to matching key trio") - save_instructions.pack() - save_input.pack(fill="both") - submit.config(text="Encrypt file/s") - submit.pack(pady="10") - crypto_mode = "enc" - elif mode == 3: #Decrypt with generated keys (password locked) - reset() - file_frame.pack(fill="both") - file_label.config(text="Filepath/s to the file/s to decrypt") - file_label.pack() - file_instructions.pack() - file_input.pack(fill="x") - passcode_frame.pack(fill="both") - passcode_label.config(text="Private key passcode") - passcode_label.pack() - passcode_instructions.config( - text=( - "Passcode must be the same " - "passcode used when the keys were created" - ) + self.header.pack(fill="x", side=tk.TOP) + self.subheader.pack(fill="x", side=tk.TOP) + self.action = tk.Frame(self.frame, bg="#1A181C", pady="5") + self.action.pack(fill="both") + self.action_label = tk.Label( + self.action, + text="Action:", + justify=tk.LEFT, + font=("Arial", str(head_font)), + bg="#1A181C", + fg="#F2DAFF", ) - passcode_instructions.pack() - passcode_input.pack(fill="x") - confirm_label.pack() - confirm_instructions.pack() - confirm_input.pack(fill="x") - save.pack(fill="both") - save_label.config(text="Key location") - save_label.pack() - save_instructions.config(text="Filepath to matching key trio") - save_instructions.pack() - save_input.pack(fill="both") - submit.config(text="Decrypt file/s") - submit.pack(pady="10") - crypto_mode = "dec" - elif mode == 4: #Decrypt with generated keys (no password) - reset() - file_frame.pack(fill="both") - file_label.config(text="Filepath/s to the file/s to decrypt") - file_label.pack() - file_instructions.pack() - file_input.pack(fill="x") - save.pack(fill="both") - save_label.config(text="Key location") - save_label.pack() - save_instructions.config(text="Filepath to matching key trio") - save_instructions.pack() - save_input.pack(fill="both") - submit.config(text="Decrypt file/s") - submit.pack(pady="10") - crypto_mode = "weak_dec" - elif mode == 5: #Only create fresh keys (password locked) - reset() - passcode_frame.pack(fill="both") - passcode_label.config(text="Set private key passcode") - passcode_label.pack() - passcode_instructions.config( - text=( - "CRITICAL: DO NOT FORGET YOUR PASSCODE.\nWITHOUT IT, " - "YOUR DATA WILL BE LOST." - ) + self.action_label.pack() + self.action_list = tk.Listbox( + self.action, + justify=tk.CENTER, + font=("Arial", str(head_font - 2)), + bg="#1A181C", + fg="#ACA0B2", + selectbackground="#643181", + selectmode=tk.SINGLE, + relief=tk.SUNKEN, + height=7 ) - passcode_instructions.pack() - passcode_input.pack(fill="x") - confirm_label.pack() - confirm_instructions.pack() - confirm_input.pack(fill="x") - save.pack(fill="both") - save_label.config(text="Save location for keys") - save_label.pack() - save_instructions.config( - text=( - "Save the keys to an empty folder, " - "and store them somewhere secure\n" - "If other key files exist in the same" - "folder, they will be overwritten" - ) + self.action_list.insert( + 1, + "Encrypt with fresh keys (password locked)" + ) + self.action_list.insert(2, "Encrypt with fresh keys (no password)") + self.action_list.insert(3, "Encrypt with generated keys") + self.action_list.insert( + 4, + "Decrypt with generated keys (password locked)" ) - save_instructions.pack() - save_input.pack(fill="both") - submit.config(text="Create keys") - submit.pack(pady="10") - crypto_mode = "just_key" - elif mode == 6: #Only create fresh keys (no password) - reset() - save.pack(fill="both") - save_label.config(text="Save location for keys") - save_label.pack() - save_instructions.config( - text=( - "Save the keys to an empty folder, " - "and store them somewhere secure\n" - "If other key files exist in the same" - "folder, they will be overwritten" + self.action_list.insert( + 5, + "Decrypt with generated keys (no password)" + ) + self.action_list.insert(6, "Only create fresh keys (password locked)") + self.action_list.insert(7, "Only create fresh keys (no password)") + self.action_list.pack(fill="both", pady="10") + if platform == "darwin": + self.submit_action = tk.Button( + self.action, + text="Begin Process", + font=("Arial", str(head_font - 2)), + fg="#643181", + highlightthickness=0, + highlightbackground="#1A181C", + pady="3", + command=lambda: self.setup(self.action_list.curselection()) + ) + else: + self.submit_action = tk.Button( + self.action, + text="Begin Process", + font=("Arial", str(head_font - 2)), + bg="#643181", + fg="#B494C7", + command=lambda: self.setup(self.action_list.curselection()) ) + self.submit_action.pack() + self.step_two = tk.Frame(self.frame, bg="#1A181C") + self.step_two.pack(fill="both") + self.file_frame = tk.Frame(self.step_two, bg="#1A181C", pady="8") + self.file_label = tk.Label( + self.file_frame, + text="If you see this, the app broke", + font=("Arial", str(head_font)), + bg="#1A181C", + fg="#F2DAFF" ) - save_instructions.pack() - save_input.pack(fill="both") - submit.config(text="Create keys") - submit.pack(pady="10") - crypto_mode = "weak_key" - - -def reset_text(entry_widget): - """Reset the string value of a tk.Entry object to an empty string + self.file_instructions = tk.Label( + self.file_frame, + text="Separate filepaths with colons (:)", + font=("Arial", str(head_font - 2)), + bg="#1A181C", + fg="#B494C7" + ) + self.file_input = tk.Entry( + self.file_frame, + font=("Arial", str(head_font - 2)), + justify=tk.CENTER, + textvariable=tk.StringVar, + bg="#1A181C", + fg="#F2DAFF", + highlightthickness=0, + insertbackground="#F2DAFF" + ) + self.passcode_frame = tk.Frame(self.step_two, bg="#1A181C", pady="8") + self.passcode_label = tk.Label( + self.passcode_frame, + text="If you see this, the app broke", + font=("Arial", str(head_font)), + bg="#1A181C", + fg="#F2DAFF" + ) + self.passcode_instructions = tk.Label( + self.passcode_frame, + text="If you see this, the app broke", + font=("Arial", str(head_font - 2)), + bg="#1A181C", + fg="#B494C7" + ) + self.passcode_input = tk.Entry( + self.passcode_frame, + font=("Arial", str(head_font - 2)), + justify=tk.CENTER, + textvariable=tk.StringVar, + show="*", + bg="#1A181C", + fg="#F2DAFF", + highlightthickness=0, + insertbackground="#F2DAFF" + ) + self.confirm_label = tk.Label( + self.passcode_frame, + text="Confirm passkey", + font=("Arial", str(head_font)), + bg="#1A181C", + fg="#F2DAFF" + ) + self.confirm_instructions = tk.Label( + self.passcode_frame, + text="Re-enter the provided passkey", + font=("Arial", str(head_font - 2)), + bg="#1A181C", + fg="#B494C7" + ) + self.confirm_input = tk.Entry( + self.passcode_frame, + font=("Arial", str(head_font - 2)), + justify=tk.CENTER, + textvariable=tk.StringVar, + show="*", + bg="#1A181C", + fg="#F2DAFF", + highlightthickness=0, + insertbackground="#F2DAFF" + ) + self.save = tk.Frame(self.step_two, bg="#1A181C", pady="8") + self.save_label = tk.Label( + self.save, + text="Save location for keys", + font=("Arial", str(head_font)), + bg="#1A181C", + fg="#F2DAFF" + ) + self.save_instructions = tk.Label( + self.save, + text="If you see this, the app broke", + font=("Arial", str(head_font - 2)), + bg="#1A181C", + fg="#B494C7" + ) + self.save_input = tk.Entry( + self.save, + font=("Arial", str(head_font - 2)), + justify=tk.CENTER, + textvariable=tk.StringVar, + bg="#1A181C", + fg="#F2DAFF", + highlightthickness=0, + insertbackground="#F2DAFF" + ) + if platform == "darwin": + self.submit = tk.Button( + self.save, + text="If you see this, the app broke", + font=("Arial", str(head_font - 2)), + fg="#643181", + highlightbackground="#1A181C", + highlightthickness=0, + pady="3", + command=lambda: self.go( + mode=self.crypto_mode, + save_folder=self.save_input.get(), + target_file=self.file_input.get(), + passkey=self.passcode_input.get(), + passcheck=self.confirm_input.get() + ) + ) + else: + self.submit = tk.Button( + self.save, + text="If you see this, the app broke", + font=("Arial", str(head_font - 2)), + bg="#643181", + fg="#B494C7", + pady="3", + command=lambda: self.go( + mode=self.crypto_mode, + save_folder=self.save_input.get(), + target_file=self.file_input.get(), + passkey=self.passcode_input.get(), + passcheck=self.confirm_input.get() + ) + ) + self.root.mainloop() - Keyword arguments: - entry_widget -- a tk.Entry object - """ - entry_widget.delete(0,tk.END) - entry_widget.insert(0,"") + def reset(self): + self.file_frame.pack_forget() + self.file_instructions.pack_forget() + self.file_label.pack_forget() + self.reset_text(self.file_input) + self.file_input.pack_forget() + self.passcode_frame.pack_forget() + self.passcode_label.pack_forget() + self.passcode_instructions.pack_forget() + self.reset_text(self.passcode_input) + self.passcode_input.pack_forget() + self.confirm_label.pack_forget() + self.confirm_instructions.pack_forget() + self.reset_text(self.confirm_input) + self.confirm_input.pack_forget() + self.save.pack_forget() + self.save_label.pack_forget() + self.save_instructions.pack_forget() + self.reset_text(self.save_input) + self.save_input.pack_forget() + self.submit.pack_forget() + def reset_text(self, entry_widget): + """Reset the string value of a tk.Entry object to an empty string + + Keyword arguments: + entry_widget -- a tk.Entry object + """ + entry_widget.delete(0,tk.END) + entry_widget.insert(0,"") -def go(mode, save_folder=None, target_file=None, passkey=None, passcheck=None): - """Perform the action corresponding to the mode, - using the input data from the user, after checking the validity - of the filepaths. + def setup(self, mode): + """"Change the GUI to match the app mode, + based on the user's action_list selection. - Keyword arguments: - mode -- the mode defined by setup() from action_list - save_folder -- the folder where the keys are or will be stored (OPTIONAL) - target_file -- the file to encrypt or decrypt (OPTIONAL) - passkey - the access code to the RSA keys that have them (OPTIONAL) - passcheck - the access code to the RSA keys that have them confirmed, - to prevent spelling errors. - """ - if check.quick_check(mode=mode, target_file_raw=target_file, save_folder=save_folder): - if mode == "key_enc" and check.password_check(passkey, passcheck): - rsa_key(passkey, save_folder) - rsa_enc(target_file, save_folder) - elif mode == "weak_key_enc": - rsa_key(passkey, save_folder) - rsa_enc(target_file, save_folder) - elif mode == "enc": - rsa_enc(target_file, save_folder) - elif mode == "dec" and check.password_check(passkey, passcheck): - rsa_dec(target_file, save_folder, passkey) - elif mode == "weak_dec": - rsa_dec(target_file, save_folder, passkey) - elif mode == "just_key" and check.password_check(passkey, passcheck): - rsa_key(passkey, save_folder) - elif mode == "weak_key": - rsa_key(passkey, save_folder) - - -root = tk.Tk() -root.wm_title("figENC") -canvas = tk.Canvas( - root, - height=700, - width=700 -) -canvas.pack(fill=tk.BOTH, expand=True) -frame = tk.Frame(canvas, bg="#1A181C") -frame.place(relwidth=1, relheight=1) - -header = tk.Label( - frame, - text="figENC", - justify=tk.CENTER, - font=("Arial", "22"), - bg="#643181", - fg="#F2DAFF", - pady="2" -) -subheader = tk.Label( - frame, - text="Industry leading encryption by FIGBERT", - justify=tk.CENTER, - font=("Arial", "16"), - bg="#643181", - fg="#F2DAFF", - pady="2" -) -header.pack(fill="x", side="top") -subheader.pack(fill="x", side="top") + Keyword arguments: + mode -- an int (0-6) corresponding with the action_list selection + """ + mode = mode[0] + if mode == 0: #Encrypt with fresh keys (password locked) + self.reset() + self.file_frame.pack(fill="both") + self.file_label.config(text="Filepath/s to the file/s to encrypt") + self.file_label.pack() + self.file_instructions.pack() + self.file_input.pack(fill="x") + self.passcode_frame.pack(fill="both") + self.passcode_label.config(text="Set private key passcode") + self.passcode_label.pack() + self.passcode_instructions.config( + text=( + "CRITICAL: DO NOT FORGET YOUR" + "PASSCODE.\nWITHOUT IT, " + "YOUR DATA WILL BE LOST." + ) + ) + self.passcode_instructions.pack() + self.passcode_input.pack(fill="x") + self.confirm_label.pack() + self.confirm_instructions.pack() + self.confirm_input.pack(fill="x") + self.save.pack(fill="both") + self.save_label.config(text="Save location for keys") + self.save_label.pack() + self.save_instructions.config( + text=( + "Save the keys to an empty folder, " + "and store them somewhere secure\n" + "If other key files exist in the same" + "folder, they will be overwritten" + ) + ) + self.save_instructions.pack() + self.save_input.pack(fill="both") + self.submit.config(text="Encrypt file/s") + self.submit.pack(pady="10") + self.crypto_mode = "key_enc" + elif mode == 1: #Encrypt with fresh keys (no password) + self.reset() + self.file_frame.pack(fill="both") + self.file_label.config(text="Filepath/s to the file/s to encrypt") + self.file_label.pack() + self.file_instructions.pack() + self.file_input.pack(fill="x") + self.save.pack(fill="both") + self.save_label.config(text="Save location for keys") + self.save_label.pack() + self.save_instructions.config( + text=( + "Save the keys to an empty folder, " + "and store them somewhere secure\n" + "If other key files exist in the same" + "folder, they will be overwritten" + ) + ) + self.save_instructions.pack() + self.save_input.pack(fill="both") + self.submit.config(text="Encrypt file/s") + self.submit.pack(pady="10") + self.crypto_mode = "weak_key_enc" + elif mode == 2: #Encrypt with generated keys + self.reset() + self.file_frame.pack(fill="both") + self.file_label.config(text="Filepath/s to the file/s to encrypt") + self.file_label.pack() + self.file_instructions.pack() + self.file_input.pack(fill="x") + self.save.pack(fill="both") + self.save_label.config(text="Key location") + self.save_label.pack() + self.save_instructions.config( + text="Filepath to matching key trio" + ) + self.save_instructions.pack() + self.save_input.pack(fill="both") + self.submit.config(text="Encrypt file/s") + self.submit.pack(pady="10") + self.crypto_mode = "enc" + elif mode == 3: #Decrypt with generated keys (password locked) + self.reset() + self.file_frame.pack(fill="both") + self.file_label.config(text="Filepath/s to the file/s to decrypt") + self.file_label.pack() + self.file_instructions.pack() + self.file_input.pack(fill="x") + self.passcode_frame.pack(fill="both") + self.passcode_label.config(text="Private key passcode") + self.passcode_label.pack() + self.passcode_instructions.config( + text=( + "Passcode must be the same " + "passcode used when the keys were created" + ) + ) + self.passcode_instructions.pack() + self.passcode_input.pack(fill="x") + self.confirm_label.pack() + self.confirm_instructions.pack() + self.confirm_input.pack(fill="x") + self.save.pack(fill="both") + self.save_label.config(text="Key location") + self.save_label.pack() + self.save_instructions.config( + text="Filepath to matching key trio" + ) + self.save_instructions.pack() + self.save_input.pack(fill="both") + self.submit.config(text="Decrypt file/s") + self.submit.pack(pady="10") + self.crypto_mode = "dec" + elif mode == 4: #Decrypt with generated keys (no password) + self.reset() + self.file_frame.pack(fill="both") + self.file_label.config(text="Filepath/s to the file/s to decrypt") + self.file_label.pack() + self.file_instructions.pack() + self.file_input.pack(fill="x") + self.save.pack(fill="both") + self.save_label.config(text="Key location") + self.save_label.pack() + self.save_instructions.config( + text="Filepath to matching key trio" + ) + self.save_instructions.pack() + self.save_input.pack(fill="both") + self.submit.config(text="Decrypt file/s") + self.submit.pack(pady="10") + self.crypto_mode = "weak_dec" + elif mode == 5: #Only create fresh keys (password locked) + self.reset() + self.passcode_frame.pack(fill="both") + self.passcode_label.config(text="Set private key passcode") + self.passcode_label.pack() + self.passcode_instructions.config( + text=( + "CRITICAL: DO NOT FORGET YOUR PASSCODE.\nWITHOUT IT, " + "YOUR DATA WILL BE LOST." + ) + ) + self.passcode_instructions.pack() + self.passcode_input.pack(fill="x") + self.confirm_label.pack() + self.confirm_instructions.pack() + self.confirm_input.pack(fill="x") + self.save.pack(fill="both") + self.save_label.config(text="Save location for keys") + self.save_label.pack() + self.save_instructions.config( + text=( + "Save the keys to an empty folder, " + "and store them somewhere secure\n" + "If other key files exist in the same" + "folder, they will be overwritten" + ) + ) + self.save_instructions.pack() + self.save_input.pack(fill="both") + self.submit.config(text="Create keys") + self.submit.pack(pady="10") + self.crypto_mode = "just_key" + elif mode == 6: #Only create fresh keys (no password) + self.reset() + self.save.pack(fill="both") + self.save_label.config(text="Save location for keys") + self.save_label.pack() + self.save_instructions.config( + text=( + "Save the keys to an empty folder, " + "and store them somewhere secure\n" + "If other key files exist in the same" + "folder, they will be overwritten" + ) + ) + self.save_instructions.pack() + self.save_input.pack(fill="both") + self.submit.config(text="Create keys") + self.submit.pack(pady="10") + self.crypto_mode = "weak_key" -action = tk.Frame(frame, bg="#1A181C", pady="5") -action.pack(fill="both") -action_label = tk.Label( - action, - text="Action:", - justify=tk.LEFT, - font=("Arial", "16"), - bg="#1A181C", - fg="#F2DAFF", -) -action_label.pack() -action_list = tk.Listbox( - action, - justify=tk.CENTER, - font=("Arial", "14"), - bg="#1A181C", - fg="#ACA0B2", - selectbackground="#643181", - selectmode=tk.SINGLE, - relief=tk.SUNKEN, - height=7 -) -action_list.insert(1, "Encrypt with fresh keys (password locked)") -action_list.insert(2, "Encrypt with fresh keys (no password)") -action_list.insert(3, "Encrypt with generated keys") -action_list.insert(4, "Decrypt with generated keys (password locked)") -action_list.insert(5, "Decrypt with generated keys (no password)") -action_list.insert(6, "Only create fresh keys (password locked)") -action_list.insert(7, "Only create fresh keys (no password)") -action_list.pack(fill="both", pady="10") -if platform == "darwin": - submit_action = tk.Button( - action, - text="Begin Process", - font=("Arial", "14"), - fg="#643181", - highlightthickness=0, - highlightbackground="#1A181C", - pady="3", - command=lambda: setup(action_list.curselection()) - ) -else: - submit_action = tk.Button( - action, - text="Begin Process", - font=("Arial", "14"), - bg="#643181", - fg="#B494C7", - command=lambda: setup(action_list.curselection()) - ) -submit_action.pack() + def go( + self, + mode, + save_folder=None, + target_file=None, + passkey=None, + passcheck=None + ): + """Perform the action corresponding to the mode, + using the input data from the user, after checking the validity + of the filepaths. -step_two = tk.Frame(frame, bg="#1A181C") -step_two.pack(fill="both") -file_frame = tk.Frame(step_two, bg="#1A181C", pady="8") -file_label = tk.Label( - file_frame, - text="If you see this, the app broke", - font=("Arial", "16"), - bg="#1A181C", - fg="#F2DAFF" -) -file_instructions = tk.Label( - file_frame, - text="Separate filepaths with colons (:)", - font=("Arial", "14"), - bg="#1A181C", - fg="#B494C7" -) -file_input = tk.Entry( - file_frame, - font=("Arial", "14"), - justify=tk.CENTER, - textvariable=tk.StringVar, - bg="#1A181C", - fg="#F2DAFF", - highlightthickness=0, - insertbackground="#F2DAFF" -) -passcode_frame = tk.Frame(step_two, bg="#1A181C", pady="8") -passcode_label = tk.Label( - passcode_frame, - text="If you see this, the app broke", - font=("Arial", "16"), - bg="#1A181C", - fg="#F2DAFF" -) -passcode_instructions = tk.Label( - passcode_frame, - text="If you see this, the app broke", - font=("Arial", "14"), - bg="#1A181C", - fg="#B494C7" -) -passcode_input = tk.Entry( - passcode_frame, - font=("Arial", "14"), - justify=tk.CENTER, - textvariable=tk.StringVar, - show="*", - bg="#1A181C", - fg="#F2DAFF", - highlightthickness=0, - insertbackground="#F2DAFF" -) -confirm_label = tk.Label( - passcode_frame, - text="Confirm passkey", - font=("Arial", "16"), - bg="#1A181C", - fg="#F2DAFF" -) -confirm_instructions = tk.Label( - passcode_frame, - text="Re-enter the provided passkey", - font=("Arial", "14"), - bg="#1A181C", - fg="#B494C7" -) -confirm_input = tk.Entry( - passcode_frame, - font=("Arial", "14"), - justify=tk.CENTER, - textvariable=tk.StringVar, - show="*", - bg="#1A181C", - fg="#F2DAFF", - highlightthickness=0, - insertbackground="#F2DAFF" -) + Keyword arguments: + mode -- the mode defined by setup() from action_list + save_folder -- the folder where the keys are or will be stored + target_file -- the file to encrypt or decrypt + passkey - the access code to the RSA keys that have them + passcheck - the access code to the RSA keys that have them confirmed, + to prevent spelling errors. + """ + if check.quick_check( + mode=mode, + target_file_raw=target_file, + save_folder=save_folder + ): + if mode == "key_enc" and check.password_check(passkey, passcheck): + rsa_key(passkey, save_folder) + rsa_enc(target_file, save_folder) + elif mode == "weak_key_enc": + rsa_key(passkey, save_folder) + rsa_enc(target_file, save_folder) + elif mode == "enc": + rsa_enc(target_file, save_folder) + elif mode == "dec" and check.password_check(passkey, passcheck): + rsa_dec(target_file, save_folder, passkey) + elif mode == "weak_dec": + rsa_dec(target_file, save_folder, passkey) + elif mode == "just_key" and check.password_check(passkey, + passcheck): + rsa_key(passkey, save_folder) + elif mode == "weak_key": + rsa_key(passkey, save_folder) -save = tk.Frame(step_two, bg="#1A181C", pady="8") -save_label = tk.Label( - save, - text="Save location for keys", - font=("Arial", "16"), - bg="#1A181C", - fg="#F2DAFF" -) -save_instructions = tk.Label( - save, - text="If you see this, the app broke", - font=("Arial", "14"), - bg="#1A181C", - fg="#B494C7" -) -save_input = tk.Entry( - save, - font=("Arial", "14"), - justify=tk.CENTER, - textvariable=tk.StringVar, - bg="#1A181C", - fg="#F2DAFF", - highlightthickness=0, - insertbackground="#F2DAFF" -) -if platform == "darwin": - submit = tk.Button( - save, - text="If you see this, the app broke", - font=("Arial", "14"), - fg="#643181", - highlightbackground="#1A181C", - highlightthickness=0, - pady="3", - command=lambda: go( - mode=crypto_mode, - save_folder=save_input.get(), - target_file=file_input.get(), - passkey=passcode_input.get(), - passcheck=confirm_input.get() - ) - ) -else: - submit = tk.Button( - save, - text="If you see this, the app broke", - font=("Arial", "14"), - bg="#643181", - fg="#B494C7", - pady="3", - command=lambda: go( - mode=crypto_mode, - save_folder=save_input.get(), - target_file=file_input.get(), - passkey=passcode_input.get(), - passcheck=confirm_input.get() - ) - ) -root.mainloop() -\ No newline at end of file +App(14, False) +\ No newline at end of file diff --git a/Scripts/settings.json b/Scripts/settings.json @@ -0,0 +1,4 @@ +{ + "font_size": 16, + "scroll": true +} +\ No newline at end of file diff --git a/Scripts/tips.json b/Scripts/tips.json @@ -0,0 +1,12 @@ +[ + "if the app widgets don't fit on the screen, adjust the font size\nor turn on the scrollbar in the settings page.", + "the app keeps itself updated automatically, so you don't have to think about it.", + "for added security, store the keys on a seperate drive from your computer\n(i.e. flash drive, cloud storage).", + "if you give someone access to your keys, they can decrypt your files.\nKeep your keys private!", + "figENC supports image encryption as well as text file encryption.\nHide your private pics!", + "password encryption on your keys enhances the encryption algorithm,\nfurther securing your files.", + "keys generated by figENC are PEM-compatible, and should\nwork with other encryption programs.", + "figENC uses a unique encryption algorithm to provide\nRSA encryption to files of any size.", + "figENC uses multilayer encryption. To encrypt or decrypt, you need\nat least two of the three keys.", + "figENC's RSA encryption is military grade, and has never been broken\nby hackers or governments." +] +\ No newline at end of file