Skip to content

Commit

Permalink
Updated Encrypc.py v1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dhhruv committed Dec 28, 2020
1 parent 57da04c commit 26ad1cc
Showing 1 changed file with 90 additions and 8 deletions.
98 changes: 90 additions & 8 deletions EncrypC.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from tkinter import *
from Cryptodome.Cipher import AES
import threading
from pathlib import Path

class EncryptionTool:
def __init__(self, user_file, user_key, user_salt):
Expand Down Expand Up @@ -151,6 +152,7 @@ def __init__(self, root):
self._cipher = None
self._file_url = tk.StringVar()
self._secret_key = tk.StringVar()
self._secret_key_check = tk.StringVar()
self._salt = tk.StringVar()
self._status = tk.StringVar()
self._status.set("---")
Expand Down Expand Up @@ -248,13 +250,13 @@ def __init__(self, root):
sticky=tk.W+tk.E+tk.N+tk.S
)

self.key_entry_label = tk.Label(
self.key_entry_label1 = tk.Label(
root,
text="Enter Key (To be Remembered while Decryption)",
bg="#eeeeee",
anchor=tk.W
)
self.key_entry_label.grid(
self.key_entry_label1.grid(
padx=12,
pady=(8, 0),
ipadx=0,
Expand All @@ -265,14 +267,14 @@ def __init__(self, root):
sticky=tk.W+tk.E+tk.N+tk.S
)

self.key_entry = tk.Entry(
self.key_entry1 = tk.Entry(
root,
textvariable=self._secret_key,
bg="#fff",
exportselection=0,
relief=tk.FLAT
)
self.key_entry.grid(
self.key_entry1.grid(
padx=15,
pady=6,
ipadx=8,
Expand All @@ -283,10 +285,45 @@ def __init__(self, root):
sticky=tk.W+tk.E+tk.N+tk.S
)

self.key_entry_label2 = tk.Label(
root,
text="Re-enter Key (Validation)",
bg="#eeeeee",
anchor=tk.W
)
self.key_entry_label2.grid(
padx=12,
pady=(8, 0),
ipadx=0,
ipady=1,
row=5,
column=0,
columnspan=4,
sticky=tk.W+tk.E+tk.N+tk.S
)

self.key_entry2 = tk.Entry(
root,
textvariable=self._secret_key_check,
bg="#fff",
exportselection=0,
relief=tk.FLAT
)
self.key_entry2.grid(
padx=15,
pady=6,
ipadx=8,
ipady=8,
row=6,
column=0,
columnspan=4,
sticky=tk.W+tk.E+tk.N+tk.S
)

self.encrypt_btn = tk.Button(
root,
text="ENCRYPT",
command=self.encrypt_callback,
command=self.e_check_callback,
bg="#27ae60",
fg="#ffffff",
bd=2,
Expand All @@ -306,7 +343,7 @@ def __init__(self, root):
self.decrypt_btn = tk.Button(
root,
text="DECRYPT",
command=self.decrypt_callback,
command=self.d_check_callback,
bg="#27ae60",
fg="#ffffff",
bd=2,
Expand Down Expand Up @@ -399,7 +436,8 @@ def selectfile_callback(self):

def freeze_controls(self):
self.file_entry.configure(state="disabled")
self.key_entry.configure(state="disabled")
self.key_entry1.configure(state="disabled")
self.key_entry2.configure(state="disabled")
self.select_btn.configure(state="disabled",bg='#aaaaaa')
self.encrypt_btn.configure(state="disabled",bg='#aaaaaa')
self.decrypt_btn.configure(state="disabled",bg='#aaaaaa')
Expand All @@ -409,14 +447,58 @@ def freeze_controls(self):

def unfreeze_controls(self):
self.file_entry.configure(state="normal")
self.key_entry.configure(state="normal")
self.key_entry1.configure(state="normal")
self.key_entry2.configure(state="normal")
self.select_btn.configure(state="normal",bg='#3498db')
self.encrypt_btn.configure(state="normal",bg='#27ae60')
self.decrypt_btn.configure(state="normal",bg='#27ae60')
self.reset_btn.configure(state="normal",bg='#717d7e')
self.stop_btn.configure(state="disabled",bg='#aaaaaa')
self.status_label.update()

def e_check_callback(self):

newPath=Path(self._file_url.get())
if newPath.is_file():
pass
else:
messagebox.showinfo("EncrypC","Please Enter a valid File URL !!")
return

if len(self._secret_key.get())==0:
messagebox.showinfo("EncrypC","Please Enter a valid Secret Key !!")
return
elif self._secret_key.get() != self._secret_key_check.get():
messagebox.showinfo("EncrypC","Passwords do not match !!")
return


self.encrypt_callback()

def d_check_callback(self):

newPath=Path(self._file_url.get())
if newPath.is_file():
pass
else:
messagebox.showinfo("EncrypC","Please Enter a valid File URL !!")
return

if self._file_url.get()[-4:] != "encr":
messagebox.showinfo("EncrypC","""Provided File is not an Encrypted File !!
Please Enter an Encrypted File to Decrypt.""")
return

if len(self._secret_key.get())==0:
messagebox.showinfo("EncrypC","Please Enter a Secret Key !!")
return
elif self._secret_key.get() != self._secret_key_check.get():
messagebox.showinfo("EncrypC","Passwords do not match !!")
return

self.decrypt_callback()


def encrypt_callback(self):
t1 = threading.Thread(target=self.encrypt_execute)
t1.start()
Expand Down

0 comments on commit 26ad1cc

Please sign in to comment.