-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconcealium.py
351 lines (292 loc) · 11.4 KB
/
concealium.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
import os
import os.path
import shutil
import tkinter as tk
from tkinter import *
from tkinter import messagebox
from tkinter.filedialog import askopenfile
from cryptography.fernet import Fernet
from zipfile import ZipFile
import webbrowser
root = tk.Tk()
root.geometry("650x400")
root.resizable(False, False)
root.title("Concealium v3.0.1")
root.config(background="#4d4e61")
#app icon
# p1 = PhotoImage(file = "concealium.png")
# root.iconphoto(False, p1)
def callback(url):
webbrowser.open_new_tab(url)
def elements():
app_banner = Label(root, text="Concealium - File Vault",
padx=15,
pady=15,
bg="#4d4e61",
fg="white",
font="Magneto 20 bold")
app_banner.grid(row=1,
column=3,
pady=10,
padx=5,
columnspan=3)
copyright_label = Label(root, text="Copyright © Ashfaaq Rifath",
padx=0,
pady=0,
bg="#4d4e61",
fg="white",)
copyright_label.grid(row=2,
column=3,
pady=0,
padx=0,
columnspan=3)
hide_button = Button(root,
text="Hide Folder",
command=hide_folder,
width=10,
bg="#ffc800",
pady=10,
padx=15,
relief=GROOVE,
font="Arial 10 bold")
hide_button.grid(row=5,
column=3,
pady=20,
padx=20)
show_button = Button(root,
text="Show Folder",
command=show_folder,
width=10,
bg="#1fab00",
pady=10,
padx=15,
relief=GROOVE,
font="Arial 10 bold")
show_button.grid(row=5,
column=4,
pady=20,
padx=20,)
encrypt_button = Button(root,
text="Encrypt Folder",
command=encrypt_folder,
width=10,
bg="#ffc800",
pady=10,
padx=15,
relief=GROOVE,
font="Arial 10 bold")
encrypt_button.grid(row=6,
column=3,
pady=20,
padx=20,)
decrypt_button = Button(root,
text="Decrypt Folder",
command=decrypt_folder,
width=10,
bg="#1fab00",
pady=10,
padx=15,
relief=GROOVE,
font="Arial 10 bold")
decrypt_button.grid(row=7,
column=3,
pady=20,
padx=20,)
zip_button = Button(root,
text="Zip Folder",
command=zip_folder,
width=10,
bg="#ffc800",
pady=10,
padx=15,
relief=GROOVE,
font="Arial 10 bold")
zip_button.grid(row=5,
column=5,
pady=20,
padx=20,)
unzip_button = Button(root,
text="Unzip Folder",
command=unzip_folder,
width=10,
bg="#1fab00",
pady=10,
padx=15,
relief=GROOVE,
font="Arial 10 bold")
unzip_button.grid(row=6,
column=5,
pady=20,
padx=20,)
make_folder = Button(root,
text="Make Folder",
command=the_folder,
width=10,
bg="#ffc800",
pady=10,
padx=15,
relief=GROOVE,
font="Arial 10 bold")
make_folder.grid(row=7,
column=5,
pady=20,
padx=20,)
github_link = Label(root, text="GitHub", font="Arial 10", fg="white", bg="#4d4e61", cursor="hand2")
github_link.grid(row=8,
pady=5,
padx=20,
column=2,)
github_link.bind("<Button-1>", lambda e:
callback("https://github.com/ashfaaqrifath/Concealium"))
save_path = "C:/Users/Public"
zip_file = "C:/Users/Public/Vault"
zip_save = os.path.join(save_path, "Vault")
key_path = os.path.join(save_path, "encryption.key")
def zip_folder():
try:
shutil.make_archive(zip_save, 'zip', zip_file)
shutil.rmtree("C:/Users/Public/Vault")
messagebox.showinfo("Success", "Folder zipped: C:/Users/Public/Vault.zip")
except FileNotFoundError:
messagebox.showerror("Error", "Folder already zipped")
def unzip_folder():
try:
zipped_folder = "C:/Users/Public/Vault.zip"
with ZipFile(zipped_folder, 'r') as zip:
zip.extractall("C:/Users/Public/Vault")
os.remove(zipped_folder)
messagebox.showinfo("Success", "Folder unzipped: C:/Users/Public/Vault")
except FileNotFoundError:
messagebox.showerror("Error", "Folder already unzipped")
def encrypt_folder():
try:
confirm = messagebox.askquestion('Encrypt Folder', 'Do you want to encrypt the Vault folder ?')
if confirm == 'yes' :
shutil.make_archive(zip_save, 'zip', zip_file)
shutil.rmtree("C:/Users/Public/Vault")
key = Fernet.generate_key()
with open(key_path, "wb") as encryptkey:
encryptkey.write(key)
fernet = Fernet(key)
user_file_encp = "C:/Users/Public/Vault.zip"
with open(user_file_encp, 'rb') as file:
original_file = file.read()
encrypt = fernet.encrypt(original_file)
with open(user_file_encp, 'wb') as encp_file:
encp_file.write(encrypt)
messagebox.showinfo("Encrypted", "Folder encrypted. DO NOT DELETE THE ENCRYPTION KEY")
else :
pass
except FileNotFoundError:
messagebox.showerror("Error", "Folder already encrypted")
def decryption():
try:
usr_password = pass_entry2.get()
if usr_password == "":
pass
#this is the password. this can be changed in the source code.
elif usr_password == "1234":
user_file_decp = "C:/Users/Public/Vault.zip"
with open(key_path, 'rb') as encp_key:
read_enc_key = encp_key.read()
fernet = Fernet(read_enc_key)
with open(user_file_decp, 'rb') as read_encp_file:
encrypted_file = read_encp_file.read()
decrypt = fernet.decrypt(encrypted_file)
with open(user_file_decp, 'wb') as decp_file:
decp_file.write(decrypt)
with ZipFile(user_file_decp, 'r') as zip:
zip.extractall("C:/Users/Public/Vault")
os.remove(user_file_decp)
messagebox.showinfo("Decrypted", "Folder decrypted: C:/Users/Public/Vault")
elif usr_password != "1234":
messagebox.showerror("Invalid password", "Wrong password")
elif not pass_entry.get():
messagebox.showerror("Invalid password", "Enter the password")
except FileNotFoundError:
messagebox.showerror("Error", "Folder already decrypted")
def decrypt_folder():
password2 = Entry(root,
width=13,
textvariable=pass_entry2,
font="Arial 11")
password2.grid(row=7,
column=4,
pady=0,
padx=0,
columnspan=1)
decrypt_button2 = Button(root,
text="Enter Password",
command=decryption,
width=10,
bg="#56abf0",
pady=10,
padx=15,
relief=GROOVE,
font="Arial 10")
decrypt_button2.grid(row=7,
column=3,
pady=20,
padx=20,)
def the_folder():
file_exists = os.path.exists('C:/Users/Public/Vault')
if file_exists == False:
os.mkdir("C:/Users/Public/Vault")
messagebox.showinfo("Folder Created", "Vault folder created: C:/Users/Public/Vault")
else:
messagebox.showinfo("Folder Exists", "Folder already exists: C:/Users/Public/Vault")
def hide_folder():
#change this file path to the desired file path
file_exists = os.path.exists('C:/Users/Public/Vault')
if file_exists == False:
os.mkdir("C:/Users/Public/Vault")
file_exists = os.path.exists('C:/Users/Public/Vault.zip')
if file_exists == True:
os.system("attrib +h /s /d C:/Users/Public/Vault.zip")
#change this file path to the desired file path
os.system("attrib +h /s /d C:/Users/Public/Vault")
messagebox.showinfo("Success", "Folder hidden: C:/Users/Public/Vault")
def show_folder():
password = Entry(root,
width=13,
textvariable=pass_entry,
font="Arial 11")
password.grid(row=6,
column=4,
pady=0,
padx=0,
columnspan=1)
show_button2 = Button(root,
text="Enter Password",
command=show_folder,
width=10,
bg="#56abf0",
pady=10,
padx=15,
relief=GROOVE,
font="Arial 10")
show_button2.grid(row=5,
column=4,
pady=20,
padx=20,)
usr_password = pass_entry.get()
if usr_password == "":
pass
#this is the password. this can be changed in the source code.
elif usr_password == "1234":
file_exists = os.path.exists('C:/Users/Public/Vault.zip')
if file_exists == True:
os.system("attrib -h /s /d C:/Users/Public/Vault.zip")
#change this file path to the desired file path
os.system("attrib -h /s /d C:/Users/Public/Vault")
messagebox.showinfo("Success", "Folder visible: C:/Users/Public/Vault")
elif usr_password != "1234":
messagebox.showerror("Invalid password", "Wrong password")
elif not pass_entry.get():
messagebox.showerror("Invalid password", "Enter the password")
var = IntVar()
pass_entry = StringVar()
pass_entry2 = StringVar()
elements()
root.mainloop()
# Copyright (c) 2023 Ashfaaq Rifath - Concealium v3.0.1