privournal 1.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- privournal-1.0.1/MainCode.py +1429 -0
- privournal-1.0.1/PKG-INFO +190 -0
- privournal-1.0.1/README.md +181 -0
- privournal-1.0.1/privournal.egg-info/PKG-INFO +190 -0
- privournal-1.0.1/privournal.egg-info/SOURCES.txt +8 -0
- privournal-1.0.1/privournal.egg-info/dependency_links.txt +1 -0
- privournal-1.0.1/privournal.egg-info/requires.txt +2 -0
- privournal-1.0.1/privournal.egg-info/top_level.txt +1 -0
- privournal-1.0.1/pyproject.toml +17 -0
- privournal-1.0.1/setup.cfg +4 -0
|
@@ -0,0 +1,1429 @@
|
|
|
1
|
+
''' PRIVOURNAL STORES NO DATA EXCEPT ACCOUNT DETAILS.
|
|
2
|
+
ECRYPTIONS AND DECRYPTIONS PURELY DONE BY LOGIC AND ENCRYPTION DATA IN USER'S ACCOUNT.
|
|
3
|
+
ENCRYPTION DATA CAN BE ALSO PASSWORD PROTECTED.
|
|
4
|
+
NOTE : ENCRYPTED TEXT HAS TO BE GIVEN BY USER IN CASE OF NO ACCOUNT'''
|
|
5
|
+
|
|
6
|
+
# FOR MY REFENECE - DATA Fetchall -> List of different records and each column's info in a tuple.
|
|
7
|
+
# THANK YOU
|
|
8
|
+
|
|
9
|
+
# Imports!
|
|
10
|
+
|
|
11
|
+
import random
|
|
12
|
+
import string
|
|
13
|
+
import json
|
|
14
|
+
import time
|
|
15
|
+
import os
|
|
16
|
+
|
|
17
|
+
from datetime import date
|
|
18
|
+
import textwrap
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
# Making the pretty format!
|
|
22
|
+
def clear():
|
|
23
|
+
print("\n" * 100)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def divider():
|
|
27
|
+
print("─" * 50)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def section(title):
|
|
31
|
+
clear()
|
|
32
|
+
print("-" * 50, title, "-" * 50)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def show_output(label, text):
|
|
36
|
+
divider()
|
|
37
|
+
print(f"{label} :")
|
|
38
|
+
print()
|
|
39
|
+
print(text)
|
|
40
|
+
print()
|
|
41
|
+
divider()
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
# Kinda like the main code!
|
|
45
|
+
status = 0
|
|
46
|
+
|
|
47
|
+
# Mark 1!
|
|
48
|
+
mark1 = {}
|
|
49
|
+
for i in range(26):
|
|
50
|
+
mark1[chr(65 + i)] = ""
|
|
51
|
+
mark1[chr(97 + i)] = ""
|
|
52
|
+
|
|
53
|
+
# ASCII Version!
|
|
54
|
+
asciiv = {}
|
|
55
|
+
for i in range(65, 91):
|
|
56
|
+
asciiv[chr(i)] = str(i) + " "
|
|
57
|
+
for j in range(97, 123):
|
|
58
|
+
asciiv[chr(j)] = str(j) + " "
|
|
59
|
+
|
|
60
|
+
# Mark 2!
|
|
61
|
+
mark2 = {}
|
|
62
|
+
for i in range(26):
|
|
63
|
+
mark2[chr(65 + i)] = str(26 - i) + " "
|
|
64
|
+
mark2[chr(97 + i)] = str(52 - i) + " "
|
|
65
|
+
|
|
66
|
+
# Mark 3!
|
|
67
|
+
mark3 = {}
|
|
68
|
+
for i in range(26):
|
|
69
|
+
mark3[chr(65 + i)] = str(2 * (i + 1)) + " "
|
|
70
|
+
mark3[chr(97 + i)] = str((2 * i) + 1) + " "
|
|
71
|
+
|
|
72
|
+
# Mark 4!
|
|
73
|
+
mark4 = {}
|
|
74
|
+
for i in range(26):
|
|
75
|
+
mark4[chr(65 + i)] = chr(90 - i) + " "
|
|
76
|
+
mark4[chr(97 + i)] = chr(122 - i) + " "
|
|
77
|
+
|
|
78
|
+
# DOTENV_CONNECTION
|
|
79
|
+
from dotenv import load_dotenv
|
|
80
|
+
import os
|
|
81
|
+
|
|
82
|
+
load_dotenv()
|
|
83
|
+
|
|
84
|
+
import mysql.connector as sql
|
|
85
|
+
|
|
86
|
+
# DB_CONNECTION
|
|
87
|
+
|
|
88
|
+
def connect_db():
|
|
89
|
+
mycon = sql.connect(
|
|
90
|
+
host=os.getenv("DB_HOST"),
|
|
91
|
+
user=os.getenv("DB_USER"),
|
|
92
|
+
password=os.getenv("DB_PASSWORD"),
|
|
93
|
+
database=os.getenv("DB_NAME")
|
|
94
|
+
)
|
|
95
|
+
cursor = mycon.cursor()
|
|
96
|
+
return mycon, cursor
|
|
97
|
+
|
|
98
|
+
def start():
|
|
99
|
+
global mycon, cursor
|
|
100
|
+
mycon, cursor = connect_db()
|
|
101
|
+
section("WELCOME!")
|
|
102
|
+
banner()
|
|
103
|
+
print()
|
|
104
|
+
print()
|
|
105
|
+
print("We help your Journals stay Private and Safe :) ")
|
|
106
|
+
time.sleep(3)
|
|
107
|
+
Menu()
|
|
108
|
+
|
|
109
|
+
def Menu():
|
|
110
|
+
section("MENU")
|
|
111
|
+
print("What would you like to do today?")
|
|
112
|
+
print()
|
|
113
|
+
print("1. Encrypt a Journal Entry")
|
|
114
|
+
print("2. Decrypt a Journal Entry")
|
|
115
|
+
print("3. Exit")
|
|
116
|
+
divider()
|
|
117
|
+
raw = input("1 OR 2 OR 3 : ")
|
|
118
|
+
print(f"DEBUG: '{raw}'")
|
|
119
|
+
ch = int(raw)
|
|
120
|
+
print()
|
|
121
|
+
print()
|
|
122
|
+
|
|
123
|
+
if ch == 1:
|
|
124
|
+
En()
|
|
125
|
+
elif ch == 2:
|
|
126
|
+
De()
|
|
127
|
+
elif ch == 3:
|
|
128
|
+
exit()
|
|
129
|
+
else:
|
|
130
|
+
print("Invalid Choice")
|
|
131
|
+
print()
|
|
132
|
+
Menu()
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
def exit():
|
|
136
|
+
section("GOODBYE")
|
|
137
|
+
print("Thank you so much for using Privournal, Have a nice day!")
|
|
138
|
+
print("Byeeeeee :)")
|
|
139
|
+
print()
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
def De():
|
|
143
|
+
section("DECRYPTION")
|
|
144
|
+
print("Let's start Decryption!")
|
|
145
|
+
print()
|
|
146
|
+
|
|
147
|
+
if status == 1:
|
|
148
|
+
|
|
149
|
+
CH = input("Do you want to Decrypt a Swiption-based Journal? (Y/N) : ")
|
|
150
|
+
print()
|
|
151
|
+
print()
|
|
152
|
+
|
|
153
|
+
if CH == "y" or CH == "Y":
|
|
154
|
+
SwipDe()
|
|
155
|
+
elif CH == "n" or CH == "N":
|
|
156
|
+
cursor.execute('''
|
|
157
|
+
SELECT jd.*
|
|
158
|
+
FROM journal_details jd
|
|
159
|
+
JOIN user_records ur
|
|
160
|
+
ON jd.user_id = ur.user_id
|
|
161
|
+
WHERE ur.username = %s
|
|
162
|
+
''', (username,))
|
|
163
|
+
|
|
164
|
+
j_data = cursor.fetchall() # Fetching Journal Data
|
|
165
|
+
|
|
166
|
+
global user_id
|
|
167
|
+
user_id = (j_data[0][1])
|
|
168
|
+
print("User_ID is", user_id)
|
|
169
|
+
print()
|
|
170
|
+
|
|
171
|
+
global j_id
|
|
172
|
+
j_id = []
|
|
173
|
+
for i in range(len(j_data)):
|
|
174
|
+
j_id.append((j_data[i][0]))
|
|
175
|
+
print("Journal_IDs : ", j_id)
|
|
176
|
+
print()
|
|
177
|
+
|
|
178
|
+
global j_name
|
|
179
|
+
j_name = []
|
|
180
|
+
for i in range(len(j_data)):
|
|
181
|
+
j_name.append(j_data[i][2])
|
|
182
|
+
print("Journal_Names : ", j_name)
|
|
183
|
+
print()
|
|
184
|
+
|
|
185
|
+
global en_key
|
|
186
|
+
en_key = []
|
|
187
|
+
for i in range(len(j_data)):
|
|
188
|
+
en_key.append(j_data[i][3])
|
|
189
|
+
for t in en_key:
|
|
190
|
+
print("Encryption Key : ", t)
|
|
191
|
+
print()
|
|
192
|
+
|
|
193
|
+
global en_date
|
|
194
|
+
en_date = []
|
|
195
|
+
for i in range(len(j_data)):
|
|
196
|
+
en_date.append(j_data[i][4])
|
|
197
|
+
for t in en_date:
|
|
198
|
+
print("Date Created : ", t)
|
|
199
|
+
print()
|
|
200
|
+
|
|
201
|
+
which_j()
|
|
202
|
+
|
|
203
|
+
print("Starting Decryption!")
|
|
204
|
+
print()
|
|
205
|
+
|
|
206
|
+
og_dict_key = json.loads(EN_KEY)
|
|
207
|
+
|
|
208
|
+
RAW = input("Enter the raw encrypted journal : ")
|
|
209
|
+
global RAWlist
|
|
210
|
+
RAWlist = RAW.split(" ")
|
|
211
|
+
|
|
212
|
+
tempstore = []
|
|
213
|
+
for i in RAWlist:
|
|
214
|
+
for key, value in og_dict_key.items():
|
|
215
|
+
if i == "":
|
|
216
|
+
tempstore.append(" ")
|
|
217
|
+
break
|
|
218
|
+
|
|
219
|
+
elif not i.isalnum():
|
|
220
|
+
tempstore.append(i)
|
|
221
|
+
break
|
|
222
|
+
|
|
223
|
+
elif (str(i) + " ") == value:
|
|
224
|
+
tempstore.append(key)
|
|
225
|
+
break
|
|
226
|
+
else:
|
|
227
|
+
continue
|
|
228
|
+
|
|
229
|
+
decrypted = "".join(tempstore)
|
|
230
|
+
print()
|
|
231
|
+
print("Decrypted Successfully!")
|
|
232
|
+
print()
|
|
233
|
+
print()
|
|
234
|
+
time.sleep(1)
|
|
235
|
+
clear()
|
|
236
|
+
show_output("Here's your Journal", decrypted)
|
|
237
|
+
print()
|
|
238
|
+
print("You can copy your decrypted journal and save it somewhere safe!")
|
|
239
|
+
print()
|
|
240
|
+
time.sleep(5)
|
|
241
|
+
Menu()
|
|
242
|
+
|
|
243
|
+
else:
|
|
244
|
+
print("Invalid Choice!")
|
|
245
|
+
|
|
246
|
+
else:
|
|
247
|
+
Ch2 = input("Do you have an Account on Privournal? (Y/N) : ")
|
|
248
|
+
print()
|
|
249
|
+
|
|
250
|
+
if Ch2 == "y" or Ch2 == "Y":
|
|
251
|
+
login()
|
|
252
|
+
elif Ch2 == "n" or Ch2 == "N":
|
|
253
|
+
|
|
254
|
+
print()
|
|
255
|
+
print('''
|
|
256
|
+
|
|
257
|
+
1. Basic Encryption
|
|
258
|
+
2. Advanced Encryption
|
|
259
|
+
|
|
260
|
+
''')
|
|
261
|
+
print()
|
|
262
|
+
print()
|
|
263
|
+
|
|
264
|
+
Ch3 = int(input("Which Encryption does your Journal have? (1 OR 2) : "))
|
|
265
|
+
print()
|
|
266
|
+
if Ch3 == 1:
|
|
267
|
+
print()
|
|
268
|
+
RAW = input("Enter the Encrypted text : ")
|
|
269
|
+
RAWlist = RAW.split(" ")
|
|
270
|
+
print()
|
|
271
|
+
print()
|
|
272
|
+
print("1. Mark 1 (A to Z from 1 to 26 respectively, and a to z from 27 to 52 respectively.)")
|
|
273
|
+
print("2. ASCII Version")
|
|
274
|
+
print("3. Mark 2 (A to Z from 26 to 1 respectively, and a to z from 52 to 26 respectively.)")
|
|
275
|
+
print(
|
|
276
|
+
"4. Mark 3 (A to Z from 2 to 52 respectively, even numbers only. \nAnd a to z from 1 to 51, odd numbers only.)")
|
|
277
|
+
print()
|
|
278
|
+
print("5. Mark 4 (A to Z from Z to A respectively and a to z from z to a respectively.)")
|
|
279
|
+
print()
|
|
280
|
+
global Ch4
|
|
281
|
+
Ch4 = int(input("Which one out of these? (1-5) : "))
|
|
282
|
+
print()
|
|
283
|
+
print("Decrypting...")
|
|
284
|
+
print()
|
|
285
|
+
time.sleep(1)
|
|
286
|
+
basicDe()
|
|
287
|
+
|
|
288
|
+
elif Ch3 == 2:
|
|
289
|
+
|
|
290
|
+
Ch5 = input("Do you have the Encryption Key? (Y/N) : ")
|
|
291
|
+
print()
|
|
292
|
+
|
|
293
|
+
if Ch5 == "y" or Ch5 == "Y":
|
|
294
|
+
given_dict_key = input("Enter the Encryption Key please : ")
|
|
295
|
+
try:
|
|
296
|
+
given_dict_key = json.loads(given_dict_key)
|
|
297
|
+
except json.decoder.JSONDecodeError:
|
|
298
|
+
print(
|
|
299
|
+
"That doesn't look like a valid Encryption Key. Please check and paste it exactly as given.")
|
|
300
|
+
print()
|
|
301
|
+
De()
|
|
302
|
+
return
|
|
303
|
+
|
|
304
|
+
print()
|
|
305
|
+
RAW = input("Enter the raw encrypted journal : ")
|
|
306
|
+
RAWlist = RAW.split(" ")
|
|
307
|
+
|
|
308
|
+
tempstore = []
|
|
309
|
+
for i in RAWlist:
|
|
310
|
+
for key, value in given_dict_key.items():
|
|
311
|
+
if i == "":
|
|
312
|
+
tempstore.append(" ")
|
|
313
|
+
break
|
|
314
|
+
|
|
315
|
+
elif not i.isalnum():
|
|
316
|
+
tempstore.append(i)
|
|
317
|
+
break
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
elif (str(i) + " ") == value:
|
|
321
|
+
tempstore.append(key)
|
|
322
|
+
break
|
|
323
|
+
|
|
324
|
+
else:
|
|
325
|
+
continue
|
|
326
|
+
|
|
327
|
+
decrypted = "".join(tempstore)
|
|
328
|
+
print()
|
|
329
|
+
print("Decrypted Successfully!")
|
|
330
|
+
print()
|
|
331
|
+
print()
|
|
332
|
+
clear()
|
|
333
|
+
time.sleep(1)
|
|
334
|
+
show_output("Here's your Journal", decrypted)
|
|
335
|
+
print()
|
|
336
|
+
print()
|
|
337
|
+
print("You can copy your decrypted journal and save it somewhere safe!")
|
|
338
|
+
print("Thank you for using Privournal!")
|
|
339
|
+
print()
|
|
340
|
+
time.sleep(5)
|
|
341
|
+
Menu()
|
|
342
|
+
|
|
343
|
+
elif Ch5 == "n" or Ch5 == "N":
|
|
344
|
+
print()
|
|
345
|
+
print(
|
|
346
|
+
"We're sorry, we cannot Decryption without the Key. \nBe sure to make an account on Privournal if you have trouble keeping Keys.")
|
|
347
|
+
print()
|
|
348
|
+
print("You will be redirected to the Menu Shortly.")
|
|
349
|
+
print()
|
|
350
|
+
time.sleep(2)
|
|
351
|
+
Menu()
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
else:
|
|
355
|
+
print("Invalid choice!")
|
|
356
|
+
print()
|
|
357
|
+
De()
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
def login():
|
|
361
|
+
section("LOGIN")
|
|
362
|
+
global username1
|
|
363
|
+
global pswd
|
|
364
|
+
username1 = input("Enter Username : ")
|
|
365
|
+
pswd1 = input("Enter Password : ")
|
|
366
|
+
|
|
367
|
+
cursor.execute(
|
|
368
|
+
"SELECT password FROM user_records WHERE username = %s",
|
|
369
|
+
(username1,)
|
|
370
|
+
)
|
|
371
|
+
|
|
372
|
+
acc_d = cursor.fetchall()
|
|
373
|
+
|
|
374
|
+
if acc_d == []:
|
|
375
|
+
print()
|
|
376
|
+
print("No such Username found in our database!")
|
|
377
|
+
|
|
378
|
+
else:
|
|
379
|
+
if pswd1 == acc_d[0][0]:
|
|
380
|
+
print()
|
|
381
|
+
print("Logged in Successfully!")
|
|
382
|
+
|
|
383
|
+
cursor.execute(
|
|
384
|
+
"SELECT * FROM user_records WHERE username = %s",
|
|
385
|
+
(username1,)
|
|
386
|
+
)
|
|
387
|
+
|
|
388
|
+
acc_d = cursor.fetchall()
|
|
389
|
+
|
|
390
|
+
global user_id
|
|
391
|
+
global username
|
|
392
|
+
global password
|
|
393
|
+
global email
|
|
394
|
+
global account_created
|
|
395
|
+
|
|
396
|
+
user_id = acc_d[0][0]
|
|
397
|
+
name = acc_d[0][1]
|
|
398
|
+
username = acc_d[0][2]
|
|
399
|
+
email = acc_d[0][3]
|
|
400
|
+
account_created = acc_d[0][4]
|
|
401
|
+
password = acc_d[0][5]
|
|
402
|
+
|
|
403
|
+
print()
|
|
404
|
+
print()
|
|
405
|
+
global status
|
|
406
|
+
status = 1
|
|
407
|
+
print()
|
|
408
|
+
|
|
409
|
+
time.sleep(1)
|
|
410
|
+
Menu()
|
|
411
|
+
|
|
412
|
+
else:
|
|
413
|
+
print()
|
|
414
|
+
print("Wrong Password.")
|
|
415
|
+
print()
|
|
416
|
+
exch = int(input("Exit or Login again? (1 OR 2) : "))
|
|
417
|
+
if exch == 1:
|
|
418
|
+
exit()
|
|
419
|
+
elif exch == 2:
|
|
420
|
+
login()
|
|
421
|
+
else:
|
|
422
|
+
print("Invalid Choice!")
|
|
423
|
+
logic()
|
|
424
|
+
|
|
425
|
+
|
|
426
|
+
def basicDe():
|
|
427
|
+
dakey = {}
|
|
428
|
+
|
|
429
|
+
if Ch4 == 1:
|
|
430
|
+
dakey = mark1
|
|
431
|
+
elif Ch4 == 2:
|
|
432
|
+
dakey = asciiv
|
|
433
|
+
elif Ch4 == 3:
|
|
434
|
+
dakey = mark2
|
|
435
|
+
elif Ch4 == 4:
|
|
436
|
+
dakey = mark3
|
|
437
|
+
elif Ch4 == 5:
|
|
438
|
+
dakey = mark4
|
|
439
|
+
else:
|
|
440
|
+
print("Invalid Option!")
|
|
441
|
+
|
|
442
|
+
delist = []
|
|
443
|
+
|
|
444
|
+
for i in RAWlist:
|
|
445
|
+
if i == "":
|
|
446
|
+
delist.append(" ")
|
|
447
|
+
else:
|
|
448
|
+
for keys, values in dakey.items():
|
|
449
|
+
if values.strip() == i:
|
|
450
|
+
delist.append(keys)
|
|
451
|
+
else:
|
|
452
|
+
continue
|
|
453
|
+
if not i.isalnum() and i != "":
|
|
454
|
+
delist.append(i)
|
|
455
|
+
|
|
456
|
+
decrypted = "".join(delist)
|
|
457
|
+
print("Successfully Decrypted!")
|
|
458
|
+
print()
|
|
459
|
+
print()
|
|
460
|
+
time.sleep(1)
|
|
461
|
+
clear()
|
|
462
|
+
show_output("Here's your Journal", decrypted)
|
|
463
|
+
print("Thank you for using Privournal!")
|
|
464
|
+
print("Be sure to make an account for smoother experience in the future :) ")
|
|
465
|
+
print()
|
|
466
|
+
print()
|
|
467
|
+
time.sleep(5)
|
|
468
|
+
Menu()
|
|
469
|
+
|
|
470
|
+
|
|
471
|
+
def En():
|
|
472
|
+
section("ENCRYPTION")
|
|
473
|
+
|
|
474
|
+
if status != 1:
|
|
475
|
+
|
|
476
|
+
Ch8 = input("Do you have an Account? (Y/N) : ")
|
|
477
|
+
print()
|
|
478
|
+
|
|
479
|
+
if Ch8 == "Y" or Ch8 == "y":
|
|
480
|
+
print("You'll be redirected to Login page, please complete the login first :) ")
|
|
481
|
+
print()
|
|
482
|
+
time.sleep(1)
|
|
483
|
+
login()
|
|
484
|
+
|
|
485
|
+
elif Ch8 == "N" or Ch8 == "n":
|
|
486
|
+
print()
|
|
487
|
+
global Ch7
|
|
488
|
+
Ch7 = input(
|
|
489
|
+
"Do you want to save encryption details on our database, \nfor future decryptions and referencing records? (Y/N) : ")
|
|
490
|
+
print()
|
|
491
|
+
|
|
492
|
+
if Ch7 == "Y" or Ch7 == "y":
|
|
493
|
+
signup()
|
|
494
|
+
|
|
495
|
+
elif Ch7 == "N" or Ch7 == "n":
|
|
496
|
+
|
|
497
|
+
print("Choose Mode of Encryption : ")
|
|
498
|
+
print()
|
|
499
|
+
print("1. Basic (Weak but holds well if you have dummies tryna read your Journal lol)")
|
|
500
|
+
print(
|
|
501
|
+
"2. Advanced (Includes Swiption And Randomised Mode - Really strong encryption, \nholds well even if you have prodigies trying to read your Journal.")
|
|
502
|
+
print()
|
|
503
|
+
print()
|
|
504
|
+
|
|
505
|
+
Ch6 = int(input("Which one? (1 OR 2) : "))
|
|
506
|
+
if Ch6 == 1:
|
|
507
|
+
print()
|
|
508
|
+
print("Welcome to Basic Encryption!")
|
|
509
|
+
print()
|
|
510
|
+
print("1. Mark 1 (A to Z from 1 to 26 respectively, and a to z from 27 to 52 respectively.)")
|
|
511
|
+
print("2. ASCII Version")
|
|
512
|
+
print("3. Mark 2 (A to Z from 26 to 1 respectively, and a to z from 52 to 26 respectively.)")
|
|
513
|
+
print(
|
|
514
|
+
"4. Mark 3 (A to Z from 2 to 52 respectively, even numbers only. \nAnd a to z from 1 to 51, odd numbers only.)")
|
|
515
|
+
print("5. Mark 4 (A to Z from Z to A respectively and a to z from z to a respectively.)")
|
|
516
|
+
print()
|
|
517
|
+
|
|
518
|
+
Ch7 = int(input("Which one out of these? (1-5) "))
|
|
519
|
+
|
|
520
|
+
if Ch7 == 1:
|
|
521
|
+
dakey = mark1
|
|
522
|
+
elif Ch7 == 2:
|
|
523
|
+
dakey = asciiv
|
|
524
|
+
elif Ch7 == 3:
|
|
525
|
+
dakey = mark2
|
|
526
|
+
elif Ch7 == 4:
|
|
527
|
+
dakey = mark3
|
|
528
|
+
elif Ch7 == 5:
|
|
529
|
+
dakey = mark4
|
|
530
|
+
else:
|
|
531
|
+
print("Invalid Option!")
|
|
532
|
+
|
|
533
|
+
global j
|
|
534
|
+
j = input("Please feed the Journal for Encryption : ")
|
|
535
|
+
print()
|
|
536
|
+
print("Encrypting...")
|
|
537
|
+
time.sleep(1)
|
|
538
|
+
journal = list(j)
|
|
539
|
+
delist = []
|
|
540
|
+
|
|
541
|
+
for i in journal:
|
|
542
|
+
if i in dakey:
|
|
543
|
+
for keys, values in dakey.items():
|
|
544
|
+
if keys == i:
|
|
545
|
+
delist.append(values)
|
|
546
|
+
else:
|
|
547
|
+
continue
|
|
548
|
+
else:
|
|
549
|
+
delist.append(i)
|
|
550
|
+
|
|
551
|
+
encrypted = "".join(delist)
|
|
552
|
+
print()
|
|
553
|
+
print("Succesfully Encrypted!")
|
|
554
|
+
print()
|
|
555
|
+
print()
|
|
556
|
+
time.sleep(1)
|
|
557
|
+
clear()
|
|
558
|
+
show_output("Here's your Encrypted text", encrypted)
|
|
559
|
+
print()
|
|
560
|
+
print("Thank you for using Privournal!")
|
|
561
|
+
print("Be sure to make an account for smoother experience in future :) ")
|
|
562
|
+
print()
|
|
563
|
+
time.sleep(5)
|
|
564
|
+
|
|
565
|
+
Menu()
|
|
566
|
+
|
|
567
|
+
elif Ch6 == 2:
|
|
568
|
+
print()
|
|
569
|
+
print()
|
|
570
|
+
print("Advanced Encryption it is then!")
|
|
571
|
+
print()
|
|
572
|
+
print()
|
|
573
|
+
|
|
574
|
+
swiption = input("Do you want to enable Swiption for a stronger Encryption? (Y/N) : ")
|
|
575
|
+
|
|
576
|
+
print()
|
|
577
|
+
print()
|
|
578
|
+
if swiption == "Y" or swiption == "y":
|
|
579
|
+
Swiption()
|
|
580
|
+
|
|
581
|
+
elif swiption == "N" or swiption == "n":
|
|
582
|
+
AdvEn()
|
|
583
|
+
|
|
584
|
+
else:
|
|
585
|
+
print("Invalid choice")
|
|
586
|
+
En()
|
|
587
|
+
|
|
588
|
+
else:
|
|
589
|
+
print("Invalid input!")
|
|
590
|
+
En()
|
|
591
|
+
|
|
592
|
+
|
|
593
|
+
else:
|
|
594
|
+
|
|
595
|
+
print("Choose Mode of Encryption : ")
|
|
596
|
+
print()
|
|
597
|
+
print("1. Basic (Weak but holds well if you have dummies tryna read your Journal lol)")
|
|
598
|
+
print(
|
|
599
|
+
"2. Advanced (Includes Swiption And Randomised Mode - Really strong encryption, \nholds well even if you have prodigies trying to read your Journal.")
|
|
600
|
+
print()
|
|
601
|
+
print()
|
|
602
|
+
|
|
603
|
+
Ch6 = int(input("Which one? (1 OR 2) : "))
|
|
604
|
+
|
|
605
|
+
if Ch6 == 1:
|
|
606
|
+
print()
|
|
607
|
+
print("Welcome to Basic Encryption!")
|
|
608
|
+
print()
|
|
609
|
+
print("1. Mark 1 (A to Z from 1 to 26 respectively, and a to z from 27 to 52 respectively.)")
|
|
610
|
+
print("2. ASCII Version")
|
|
611
|
+
print("3. Mark 2 (A to Z from 26 to 1 respectively, and a to z from 52 to 26 respectively.)")
|
|
612
|
+
print(
|
|
613
|
+
"4. Mark 3 (A to Z from 2 to 52 respectively, even numbers only. \nAnd a to z from 1 to 51, odd numbers only.)")
|
|
614
|
+
print()
|
|
615
|
+
print("5. Mark 4 (A to Z from Z to A respectively and a to z from z to a respectively.)")
|
|
616
|
+
print()
|
|
617
|
+
|
|
618
|
+
Ch7 = int(input("Choose one of these (1-5) : "))
|
|
619
|
+
print()
|
|
620
|
+
|
|
621
|
+
j = input("Please feed the Journal for Encryption : ")
|
|
622
|
+
journal = list(j)
|
|
623
|
+
print()
|
|
624
|
+
|
|
625
|
+
j_name = input("Please name your Journal : ")
|
|
626
|
+
|
|
627
|
+
if Ch7 == 1:
|
|
628
|
+
dakey = mark1
|
|
629
|
+
elif Ch7 == 2:
|
|
630
|
+
dakey = asciiv
|
|
631
|
+
elif Ch7 == 3:
|
|
632
|
+
dakey = mark2
|
|
633
|
+
elif Ch7 == 4:
|
|
634
|
+
dakey = mark3
|
|
635
|
+
elif Ch7 == 5:
|
|
636
|
+
dakey = mark4
|
|
637
|
+
else:
|
|
638
|
+
print("Invalid Option!")
|
|
639
|
+
|
|
640
|
+
print()
|
|
641
|
+
print("Encrypting...")
|
|
642
|
+
time.sleep(1)
|
|
643
|
+
delist = []
|
|
644
|
+
|
|
645
|
+
for i in journal:
|
|
646
|
+
if i in dakey:
|
|
647
|
+
for keys, values in dakey.items():
|
|
648
|
+
if keys == i:
|
|
649
|
+
delist.append(values)
|
|
650
|
+
else:
|
|
651
|
+
continue
|
|
652
|
+
else:
|
|
653
|
+
delist.append(i)
|
|
654
|
+
|
|
655
|
+
encrypted = "".join(delist)
|
|
656
|
+
print()
|
|
657
|
+
|
|
658
|
+
journal_name = j_name
|
|
659
|
+
encryption_key = json.dumps(dakey)
|
|
660
|
+
encryption_date = date.today()
|
|
661
|
+
|
|
662
|
+
cursor.execute(
|
|
663
|
+
"""
|
|
664
|
+
INSERT INTO journal_details
|
|
665
|
+
(user_id, journal_name, encryption_key, encryption_date)
|
|
666
|
+
VALUES (%s, %s, %s, %s)
|
|
667
|
+
""",
|
|
668
|
+
(user_id, journal_name, encryption_key, encryption_date))
|
|
669
|
+
|
|
670
|
+
mycon.commit()
|
|
671
|
+
print("Successfully Encrypted!")
|
|
672
|
+
print()
|
|
673
|
+
print()
|
|
674
|
+
time.sleep(1)
|
|
675
|
+
clear()
|
|
676
|
+
show_output("Here's your Encrypted text", encrypted)
|
|
677
|
+
print()
|
|
678
|
+
print("Thank you for using Privournal!")
|
|
679
|
+
print("You'll be redirected to the menu.")
|
|
680
|
+
print()
|
|
681
|
+
print()
|
|
682
|
+
|
|
683
|
+
time.sleep(5)
|
|
684
|
+
Menu()
|
|
685
|
+
|
|
686
|
+
elif Ch6 == 2:
|
|
687
|
+
print()
|
|
688
|
+
print()
|
|
689
|
+
print("Advanced Encryption it is then!")
|
|
690
|
+
print()
|
|
691
|
+
print()
|
|
692
|
+
|
|
693
|
+
swiption = input("Do you want to enable Swiption for a stronger Encryption? (Y/N) : ")
|
|
694
|
+
|
|
695
|
+
print()
|
|
696
|
+
if swiption == "Y" or swiption == "y":
|
|
697
|
+
Swiption()
|
|
698
|
+
|
|
699
|
+
elif swiption == "N" or swiption == "n":
|
|
700
|
+
AdvEn()
|
|
701
|
+
|
|
702
|
+
else:
|
|
703
|
+
print("Invalid choice")
|
|
704
|
+
En()
|
|
705
|
+
else:
|
|
706
|
+
print("Invalid input!")
|
|
707
|
+
AdvEn()
|
|
708
|
+
|
|
709
|
+
|
|
710
|
+
def AdvEn():
|
|
711
|
+
global journal
|
|
712
|
+
global enlist
|
|
713
|
+
|
|
714
|
+
Ch_rand = input("Do you want to enable Randomised Encryption for more ease and security? (Y/N) ")
|
|
715
|
+
print()
|
|
716
|
+
|
|
717
|
+
if Ch_rand == "y" or Ch_rand == "Y":
|
|
718
|
+
AdvRand()
|
|
719
|
+
|
|
720
|
+
elif Ch_rand == "n" or Ch_rand == "N":
|
|
721
|
+
if status != 1:
|
|
722
|
+
|
|
723
|
+
enlist = []
|
|
724
|
+
global cover_dict
|
|
725
|
+
cover_dict = {}
|
|
726
|
+
|
|
727
|
+
feed()
|
|
728
|
+
|
|
729
|
+
if not journal:
|
|
730
|
+
print("Empty Journal!")
|
|
731
|
+
feed()
|
|
732
|
+
else:
|
|
733
|
+
print("Journal Uploaded!")
|
|
734
|
+
|
|
735
|
+
print("Choose cover for each letter!")
|
|
736
|
+
print()
|
|
737
|
+
|
|
738
|
+
global trackHEH
|
|
739
|
+
trackHEH = []
|
|
740
|
+
|
|
741
|
+
global x
|
|
742
|
+
|
|
743
|
+
for x in journal:
|
|
744
|
+
if x.isalpha() and x not in cover_dict:
|
|
745
|
+
coverr()
|
|
746
|
+
|
|
747
|
+
elif x in cover_dict:
|
|
748
|
+
cover = cover_dict[x]
|
|
749
|
+
enlist.append(cover)
|
|
750
|
+
trackHEH.append(cover)
|
|
751
|
+
else:
|
|
752
|
+
enlist.append(x)
|
|
753
|
+
|
|
754
|
+
print()
|
|
755
|
+
print("Encrypting...")
|
|
756
|
+
time.sleep(1)
|
|
757
|
+
finalenlist = "".join(enlist)
|
|
758
|
+
print()
|
|
759
|
+
print("Successfully Encrypted!")
|
|
760
|
+
print()
|
|
761
|
+
time.sleep(1)
|
|
762
|
+
clear()
|
|
763
|
+
show_output("Here's the encrypted Journal", finalenlist)
|
|
764
|
+
print()
|
|
765
|
+
print("Here's the Encryption Key : ", json.dumps(cover_dict))
|
|
766
|
+
print()
|
|
767
|
+
print("You'll be redirected to the a new page.")
|
|
768
|
+
print()
|
|
769
|
+
print()
|
|
770
|
+
time.sleep(7)
|
|
771
|
+
Menu()
|
|
772
|
+
|
|
773
|
+
else:
|
|
774
|
+
|
|
775
|
+
enlist = []
|
|
776
|
+
|
|
777
|
+
cover_dict = {}
|
|
778
|
+
|
|
779
|
+
journal = input("Please feed the Journal for Encryption : ")
|
|
780
|
+
j_name = input("Please name your Journal : ")
|
|
781
|
+
print()
|
|
782
|
+
print()
|
|
783
|
+
|
|
784
|
+
if not journal:
|
|
785
|
+
print("Empty Journal!")
|
|
786
|
+
feed()
|
|
787
|
+
else:
|
|
788
|
+
print("Journal Uploaded!")
|
|
789
|
+
|
|
790
|
+
print("Choose cover for each letter man!")
|
|
791
|
+
print()
|
|
792
|
+
|
|
793
|
+
for x in journal:
|
|
794
|
+
if x.isalpha() and x not in cover_dict:
|
|
795
|
+
print("What should be the cover for", x, "?")
|
|
796
|
+
print()
|
|
797
|
+
cover = input("Cover = ")
|
|
798
|
+
cover = cover + " "
|
|
799
|
+
cover_dict[x] = cover
|
|
800
|
+
enlist.append(cover)
|
|
801
|
+
elif x in cover_dict:
|
|
802
|
+
cover = cover_dict[x]
|
|
803
|
+
enlist.append(cover)
|
|
804
|
+
else:
|
|
805
|
+
enlist.append(x)
|
|
806
|
+
|
|
807
|
+
print()
|
|
808
|
+
print("Encrypting...")
|
|
809
|
+
time.sleep(1)
|
|
810
|
+
finalenlist = "".join(enlist)
|
|
811
|
+
|
|
812
|
+
journal_name = j_name
|
|
813
|
+
|
|
814
|
+
encryption_key = json.dumps(cover_dict)
|
|
815
|
+
encryption_date = date.today()
|
|
816
|
+
|
|
817
|
+
cursor.execute(
|
|
818
|
+
"""
|
|
819
|
+
INSERT INTO journal_details
|
|
820
|
+
(user_id, journal_name, encryption_key, encryption_date)
|
|
821
|
+
VALUES (%s, %s, %s, %s)
|
|
822
|
+
""",
|
|
823
|
+
(user_id, journal_name, encryption_key, encryption_date))
|
|
824
|
+
mycon.commit()
|
|
825
|
+
|
|
826
|
+
print()
|
|
827
|
+
print("Successfully Encrypted!")
|
|
828
|
+
print()
|
|
829
|
+
time.sleep(1)
|
|
830
|
+
clear()
|
|
831
|
+
show_output("Here's your Encrypted text", finalenlist)
|
|
832
|
+
print()
|
|
833
|
+
print()
|
|
834
|
+
print("You'll be redirected to the a new page.")
|
|
835
|
+
print()
|
|
836
|
+
print()
|
|
837
|
+
time.sleep(5)
|
|
838
|
+
Menu()
|
|
839
|
+
|
|
840
|
+
else:
|
|
841
|
+
print("Invalid input!")
|
|
842
|
+
AdvEn()
|
|
843
|
+
|
|
844
|
+
|
|
845
|
+
def feed():
|
|
846
|
+
global journal
|
|
847
|
+
global j_name
|
|
848
|
+
journal = input("Please feed the Journal for Encryption : ")
|
|
849
|
+
j_name = input("Please name your Journal : ")
|
|
850
|
+
|
|
851
|
+
|
|
852
|
+
def coverr():
|
|
853
|
+
print("What should be the cover for", x, "?")
|
|
854
|
+
global cover
|
|
855
|
+
cover = input("Cover = ")
|
|
856
|
+
if cover not in trackHEH:
|
|
857
|
+
print()
|
|
858
|
+
cover = cover + " "
|
|
859
|
+
cover_dict[x] = cover
|
|
860
|
+
enlist.append(cover)
|
|
861
|
+
trackHEH.append(cover)
|
|
862
|
+
else:
|
|
863
|
+
print("2 letters can't have the same cover na! ")
|
|
864
|
+
coverr()
|
|
865
|
+
|
|
866
|
+
|
|
867
|
+
def signup():
|
|
868
|
+
section("SIGN UP")
|
|
869
|
+
|
|
870
|
+
cursor.execute("SELECT COUNT(DISTINCT username) FROM user_records")
|
|
871
|
+
global user_id
|
|
872
|
+
user_id = cursor.fetchone()[0]
|
|
873
|
+
|
|
874
|
+
tusername = input("Set a username : ")
|
|
875
|
+
print()
|
|
876
|
+
if len(tusername) > 16:
|
|
877
|
+
print("Invalid! It should be at most 16 characters.")
|
|
878
|
+
print()
|
|
879
|
+
print()
|
|
880
|
+
time.sleep(1)
|
|
881
|
+
signup()
|
|
882
|
+
|
|
883
|
+
elif " " in tusername:
|
|
884
|
+
print("Spaces not allowed!")
|
|
885
|
+
print()
|
|
886
|
+
print()
|
|
887
|
+
time.sleep(1)
|
|
888
|
+
signup()
|
|
889
|
+
|
|
890
|
+
elif len(tusername) < 6:
|
|
891
|
+
print("Should be atleast 6 characters long!")
|
|
892
|
+
print()
|
|
893
|
+
print()
|
|
894
|
+
time.sleep(1)
|
|
895
|
+
signup()
|
|
896
|
+
|
|
897
|
+
else:
|
|
898
|
+
global username
|
|
899
|
+
username = tusername
|
|
900
|
+
|
|
901
|
+
tpswd = input("Set a password : ")
|
|
902
|
+
print()
|
|
903
|
+
|
|
904
|
+
if len(tpswd) > 16:
|
|
905
|
+
print("Invalid! It should be at most 18 characters.")
|
|
906
|
+
print()
|
|
907
|
+
print()
|
|
908
|
+
time.sleep(1)
|
|
909
|
+
signup()
|
|
910
|
+
|
|
911
|
+
elif " " in tpswd:
|
|
912
|
+
print("Spaces not allowed!")
|
|
913
|
+
print()
|
|
914
|
+
print()
|
|
915
|
+
time.sleep(1)
|
|
916
|
+
signup()
|
|
917
|
+
|
|
918
|
+
elif len(tpswd) < 8:
|
|
919
|
+
print("Should be atleast 8 characters long!")
|
|
920
|
+
print()
|
|
921
|
+
print()
|
|
922
|
+
time.sleep(1)
|
|
923
|
+
signup()
|
|
924
|
+
|
|
925
|
+
elif tpswd == username:
|
|
926
|
+
print("Username and password cannot be same!")
|
|
927
|
+
time.sleep(1)
|
|
928
|
+
signup()
|
|
929
|
+
|
|
930
|
+
else:
|
|
931
|
+
t_conf_pswd = input("Confrim password : ")
|
|
932
|
+
|
|
933
|
+
if t_conf_pswd == tpswd:
|
|
934
|
+
password = tpswd
|
|
935
|
+
|
|
936
|
+
name = input("Enter your name : ")
|
|
937
|
+
email = input("Enter email please : ")
|
|
938
|
+
account_created = date.today()
|
|
939
|
+
print()
|
|
940
|
+
cursor.execute(
|
|
941
|
+
"""
|
|
942
|
+
INSERT INTO user_records
|
|
943
|
+
(user_id, first_name, username, email, account_created, password)
|
|
944
|
+
VALUES (%s, %s, %s, %s, %s, %s)
|
|
945
|
+
""",
|
|
946
|
+
(user_id, name, username, email, account_created, password))
|
|
947
|
+
mycon.commit()
|
|
948
|
+
print()
|
|
949
|
+
print("Account made succesfully!")
|
|
950
|
+
global status
|
|
951
|
+
status = 1
|
|
952
|
+
print()
|
|
953
|
+
print("You'll be redirected to the menu, you can now start Encrypting and Decrypting without hassle! ")
|
|
954
|
+
time.sleep(1)
|
|
955
|
+
print()
|
|
956
|
+
Menu()
|
|
957
|
+
|
|
958
|
+
|
|
959
|
+
else:
|
|
960
|
+
print("The passwords don't match.")
|
|
961
|
+
signup()
|
|
962
|
+
|
|
963
|
+
|
|
964
|
+
def which_j():
|
|
965
|
+
Ch = int(input("Which Journal do you want to Decrypt? (Enter Journal_ID) : "))
|
|
966
|
+
print()
|
|
967
|
+
|
|
968
|
+
if Ch not in j_id:
|
|
969
|
+
print("Journal not found. Check the ID again!")
|
|
970
|
+
which_j()
|
|
971
|
+
|
|
972
|
+
else:
|
|
973
|
+
for i in range(len(j_id)):
|
|
974
|
+
|
|
975
|
+
if j_id[i] == Ch:
|
|
976
|
+
global EN_KEY
|
|
977
|
+
EN_KEY = en_key[i]
|
|
978
|
+
else:
|
|
979
|
+
continue
|
|
980
|
+
|
|
981
|
+
|
|
982
|
+
def Swiption():
|
|
983
|
+
section("SWIPTION ENCRYPTION")
|
|
984
|
+
|
|
985
|
+
print("Welcome to Swiption Encryption - Our most secure form of Encryption!")
|
|
986
|
+
print()
|
|
987
|
+
print("Note that Swiption by default takes use of Randomised Mode.")
|
|
988
|
+
print()
|
|
989
|
+
|
|
990
|
+
if status != 1:
|
|
991
|
+
print("For Swiption, having an account is mandatory!")
|
|
992
|
+
Ch20 = input("Do you have an Account (Y/N) : ")
|
|
993
|
+
|
|
994
|
+
if Ch20 == "Y" or Ch20 == "y":
|
|
995
|
+
print("Then first please Login :) ")
|
|
996
|
+
print()
|
|
997
|
+
login()
|
|
998
|
+
elif Ch20 == "N" or Ch20 == "n":
|
|
999
|
+
print("Please Signup or continue without Swiption :) ")
|
|
1000
|
+
print("You'll be redirected to the menu ")
|
|
1001
|
+
print()
|
|
1002
|
+
time.sleep(2)
|
|
1003
|
+
Menu()
|
|
1004
|
+
else:
|
|
1005
|
+
print("Invalid Choice!")
|
|
1006
|
+
Swiption()
|
|
1007
|
+
|
|
1008
|
+
else:
|
|
1009
|
+
|
|
1010
|
+
print("A life is at what occurrence would the letter's cover be changed.")
|
|
1011
|
+
print()
|
|
1012
|
+
|
|
1013
|
+
global l
|
|
1014
|
+
l = int(input("Choose life : "))
|
|
1015
|
+
print()
|
|
1016
|
+
|
|
1017
|
+
enlist = []
|
|
1018
|
+
|
|
1019
|
+
cover_dict = []
|
|
1020
|
+
for i in range(l + 10):
|
|
1021
|
+
cover_dict.append({})
|
|
1022
|
+
|
|
1023
|
+
j = input("Please feed the Journal for Encryption : ")
|
|
1024
|
+
|
|
1025
|
+
j_name = input("Please name your Journal : ")
|
|
1026
|
+
|
|
1027
|
+
if not j:
|
|
1028
|
+
print("Empty Journal!")
|
|
1029
|
+
Swiption()
|
|
1030
|
+
else:
|
|
1031
|
+
print("Journal Uploaded!")
|
|
1032
|
+
|
|
1033
|
+
print()
|
|
1034
|
+
print("Encrypting...")
|
|
1035
|
+
time.sleep(1)
|
|
1036
|
+
|
|
1037
|
+
m = 0
|
|
1038
|
+
|
|
1039
|
+
global ldict
|
|
1040
|
+
ldict = {}
|
|
1041
|
+
|
|
1042
|
+
for i in range(26):
|
|
1043
|
+
ldict[chr(65 + i)] = 0
|
|
1044
|
+
ldict[chr(97 + i)] = 0
|
|
1045
|
+
|
|
1046
|
+
for i in j:
|
|
1047
|
+
|
|
1048
|
+
if i.isalpha():
|
|
1049
|
+
place = ldict[i] // l
|
|
1050
|
+
|
|
1051
|
+
if i.isalpha() and i not in cover_dict[place]:
|
|
1052
|
+
|
|
1053
|
+
ldict[i] += 1
|
|
1054
|
+
|
|
1055
|
+
if (place * l) + 1 == ldict[i] and ldict[i] != 0:
|
|
1056
|
+
cover_dict.append({})
|
|
1057
|
+
|
|
1058
|
+
cover = "".join(
|
|
1059
|
+
random.choices(string.ascii_letters + string.digits, k=6)
|
|
1060
|
+
)
|
|
1061
|
+
|
|
1062
|
+
cover = cover + " "
|
|
1063
|
+
|
|
1064
|
+
cover_dict[place][i] = cover
|
|
1065
|
+
enlist.append(cover)
|
|
1066
|
+
|
|
1067
|
+
|
|
1068
|
+
elif i in cover_dict[place]:
|
|
1069
|
+
|
|
1070
|
+
cover = cover_dict[place][i]
|
|
1071
|
+
enlist.append(cover)
|
|
1072
|
+
|
|
1073
|
+
ldict[i] += 1
|
|
1074
|
+
|
|
1075
|
+
else:
|
|
1076
|
+
continue
|
|
1077
|
+
|
|
1078
|
+
elif i == " ":
|
|
1079
|
+
enlist.append(i)
|
|
1080
|
+
|
|
1081
|
+
else:
|
|
1082
|
+
enlist.append(i)
|
|
1083
|
+
|
|
1084
|
+
finalenlist = "".join(enlist)
|
|
1085
|
+
|
|
1086
|
+
journal_name = j_name
|
|
1087
|
+
|
|
1088
|
+
encryption_key = json.dumps(cover_dict)
|
|
1089
|
+
encryption_date = date.today()
|
|
1090
|
+
|
|
1091
|
+
cursor.execute(
|
|
1092
|
+
"""
|
|
1093
|
+
INSERT INTO swiption_details
|
|
1094
|
+
(user_id, journal_name, encryption_date,
|
|
1095
|
+
encryption_key, life)
|
|
1096
|
+
VALUES (%s, %s, %s, %s, %s)
|
|
1097
|
+
""",
|
|
1098
|
+
(
|
|
1099
|
+
user_id,
|
|
1100
|
+
journal_name,
|
|
1101
|
+
encryption_date,
|
|
1102
|
+
encryption_key,
|
|
1103
|
+
l
|
|
1104
|
+
)
|
|
1105
|
+
)
|
|
1106
|
+
|
|
1107
|
+
mycon.commit()
|
|
1108
|
+
mycon.commit()
|
|
1109
|
+
|
|
1110
|
+
print()
|
|
1111
|
+
print("Successfully Encrypted!")
|
|
1112
|
+
print()
|
|
1113
|
+
time.sleep(1)
|
|
1114
|
+
clear()
|
|
1115
|
+
show_output("Here's your Encrypted text", finalenlist)
|
|
1116
|
+
print()
|
|
1117
|
+
print("You'll be redirected to the a new page.")
|
|
1118
|
+
print()
|
|
1119
|
+
print()
|
|
1120
|
+
time.sleep(5)
|
|
1121
|
+
Menu()
|
|
1122
|
+
|
|
1123
|
+
|
|
1124
|
+
def SwipDe():
|
|
1125
|
+
cursor.execute(
|
|
1126
|
+
'''
|
|
1127
|
+
SELECT sd.*
|
|
1128
|
+
FROM swiption_details sd
|
|
1129
|
+
JOIN user_records ur
|
|
1130
|
+
ON sd.user_id = ur.user_id
|
|
1131
|
+
WHERE ur.username = %s
|
|
1132
|
+
''',
|
|
1133
|
+
(username,)
|
|
1134
|
+
)
|
|
1135
|
+
|
|
1136
|
+
j_data = cursor.fetchall()
|
|
1137
|
+
|
|
1138
|
+
global user_id
|
|
1139
|
+
user_id = j_data[0][1]
|
|
1140
|
+
print("User_ID is", user_id)
|
|
1141
|
+
|
|
1142
|
+
print()
|
|
1143
|
+
|
|
1144
|
+
global s_id
|
|
1145
|
+
s_id = []
|
|
1146
|
+
for i in range(len(j_data)):
|
|
1147
|
+
s_id.append(j_data[i][0])
|
|
1148
|
+
|
|
1149
|
+
print("Swiption_IDs :", s_id)
|
|
1150
|
+
|
|
1151
|
+
print()
|
|
1152
|
+
|
|
1153
|
+
global j_name
|
|
1154
|
+
j_name = []
|
|
1155
|
+
for i in range(len(j_data)):
|
|
1156
|
+
j_name.append(j_data[i][2])
|
|
1157
|
+
|
|
1158
|
+
print("Journal_Names :", j_name)
|
|
1159
|
+
print()
|
|
1160
|
+
|
|
1161
|
+
global en_date
|
|
1162
|
+
en_date = []
|
|
1163
|
+
for i in range(len(j_data)):
|
|
1164
|
+
en_date.append(j_data[i][3])
|
|
1165
|
+
|
|
1166
|
+
for j in en_date:
|
|
1167
|
+
print("Date Created :", j)
|
|
1168
|
+
print()
|
|
1169
|
+
|
|
1170
|
+
global en_key
|
|
1171
|
+
en_key = []
|
|
1172
|
+
for i in range(len(j_data)):
|
|
1173
|
+
en_key.append(j_data[i][4])
|
|
1174
|
+
|
|
1175
|
+
for t in en_key:
|
|
1176
|
+
print(t)
|
|
1177
|
+
|
|
1178
|
+
print()
|
|
1179
|
+
|
|
1180
|
+
global life
|
|
1181
|
+
life = []
|
|
1182
|
+
for i in range(len(j_data)):
|
|
1183
|
+
life.append(j_data[i][5])
|
|
1184
|
+
|
|
1185
|
+
print("Life Values :", life)
|
|
1186
|
+
print()
|
|
1187
|
+
|
|
1188
|
+
Ch = int(input("Which Journal do you want to Decrypt? (Enter Swiption_ID) : "))
|
|
1189
|
+
print()
|
|
1190
|
+
|
|
1191
|
+
global l
|
|
1192
|
+
idx = s_id.index(Ch)
|
|
1193
|
+
l = life[idx]
|
|
1194
|
+
|
|
1195
|
+
if Ch not in s_id:
|
|
1196
|
+
print("Journal not found. Check the ID again!")
|
|
1197
|
+
SwipDe()
|
|
1198
|
+
|
|
1199
|
+
else:
|
|
1200
|
+
for i in range(len(s_id)):
|
|
1201
|
+
|
|
1202
|
+
if s_id[i] == Ch:
|
|
1203
|
+
global EN_KEY
|
|
1204
|
+
EN_KEY = en_key[i]
|
|
1205
|
+
else:
|
|
1206
|
+
continue
|
|
1207
|
+
|
|
1208
|
+
print("Starting Decryption!")
|
|
1209
|
+
print("Decrypting...")
|
|
1210
|
+
print()
|
|
1211
|
+
time.sleep(1)
|
|
1212
|
+
|
|
1213
|
+
og_dict_key = json.loads(EN_KEY)
|
|
1214
|
+
|
|
1215
|
+
RAW = input("Enter the raw encrypted journal : ")
|
|
1216
|
+
RAWlist = RAW.split(" ")
|
|
1217
|
+
|
|
1218
|
+
tempstore = []
|
|
1219
|
+
|
|
1220
|
+
for i in RAWlist:
|
|
1221
|
+
|
|
1222
|
+
if i == "":
|
|
1223
|
+
tempstore.append(" ")
|
|
1224
|
+
continue
|
|
1225
|
+
|
|
1226
|
+
elif not i.isalnum():
|
|
1227
|
+
tempstore.append(i)
|
|
1228
|
+
continue
|
|
1229
|
+
|
|
1230
|
+
for d in og_dict_key:
|
|
1231
|
+
for key, value in d.items():
|
|
1232
|
+
|
|
1233
|
+
if i == value.strip():
|
|
1234
|
+
tempstore.append(key)
|
|
1235
|
+
break
|
|
1236
|
+
else:
|
|
1237
|
+
continue
|
|
1238
|
+
|
|
1239
|
+
break
|
|
1240
|
+
|
|
1241
|
+
decrypted = "".join(tempstore)
|
|
1242
|
+
print()
|
|
1243
|
+
print("Decrypted Successfully!")
|
|
1244
|
+
print()
|
|
1245
|
+
print()
|
|
1246
|
+
time.sleep(1)
|
|
1247
|
+
clear()
|
|
1248
|
+
show_output("Here's your Encrypted text", decrypted)
|
|
1249
|
+
print()
|
|
1250
|
+
print("You will be redirect to Menu in 10 seconds :) ")
|
|
1251
|
+
print()
|
|
1252
|
+
print("You can copy your decrypted journal and save it somewhere safe!")
|
|
1253
|
+
print()
|
|
1254
|
+
time.sleep(5)
|
|
1255
|
+
Menu()
|
|
1256
|
+
|
|
1257
|
+
|
|
1258
|
+
def AdvRand():
|
|
1259
|
+
section("RANDOMISED ENCRYPTION")
|
|
1260
|
+
if status == 1:
|
|
1261
|
+
|
|
1262
|
+
enlist = []
|
|
1263
|
+
cover_dict = {}
|
|
1264
|
+
|
|
1265
|
+
feed()
|
|
1266
|
+
|
|
1267
|
+
if not journal:
|
|
1268
|
+
print("Empty Journal!")
|
|
1269
|
+
feed()
|
|
1270
|
+
else:
|
|
1271
|
+
print("Journal Uploaded!")
|
|
1272
|
+
|
|
1273
|
+
print()
|
|
1274
|
+
|
|
1275
|
+
trackHEH = []
|
|
1276
|
+
|
|
1277
|
+
for x in journal:
|
|
1278
|
+
if x.isalpha() and x not in cover_dict:
|
|
1279
|
+
|
|
1280
|
+
cover = "".join(random.choices(
|
|
1281
|
+
string.ascii_letters + string.digits,
|
|
1282
|
+
k=6
|
|
1283
|
+
))
|
|
1284
|
+
|
|
1285
|
+
print()
|
|
1286
|
+
cover = cover + " "
|
|
1287
|
+
cover_dict[x] = cover
|
|
1288
|
+
enlist.append(cover)
|
|
1289
|
+
trackHEH.append(cover)
|
|
1290
|
+
|
|
1291
|
+
|
|
1292
|
+
elif x in cover_dict:
|
|
1293
|
+
cover = cover_dict[x]
|
|
1294
|
+
enlist.append(cover)
|
|
1295
|
+
trackHEH.append(cover)
|
|
1296
|
+
else:
|
|
1297
|
+
enlist.append(x)
|
|
1298
|
+
|
|
1299
|
+
print()
|
|
1300
|
+
print("Encrypting...")
|
|
1301
|
+
time.sleep(1)
|
|
1302
|
+
|
|
1303
|
+
journal_name = j_name
|
|
1304
|
+
|
|
1305
|
+
encryption_key = json.dumps(cover_dict)
|
|
1306
|
+
encryption_date = date.today()
|
|
1307
|
+
|
|
1308
|
+
cursor.execute(
|
|
1309
|
+
"""
|
|
1310
|
+
INSERT INTO journal_details
|
|
1311
|
+
(user_id, journal_name, encryption_key, encryption_date)
|
|
1312
|
+
VALUES (%s, %s, %s, %s)
|
|
1313
|
+
""",
|
|
1314
|
+
(user_id, journal_name, encryption_key, encryption_date))
|
|
1315
|
+
mycon.commit()
|
|
1316
|
+
|
|
1317
|
+
finalenlist = "".join(enlist)
|
|
1318
|
+
print()
|
|
1319
|
+
print("Successfully Encrypted!")
|
|
1320
|
+
print()
|
|
1321
|
+
print()
|
|
1322
|
+
time.sleep(1)
|
|
1323
|
+
clear()
|
|
1324
|
+
show_output("Here's your Encrypted text", finalenlist)
|
|
1325
|
+
print()
|
|
1326
|
+
print("You'll be redirected to the a new page.")
|
|
1327
|
+
print()
|
|
1328
|
+
print()
|
|
1329
|
+
time.sleep(5)
|
|
1330
|
+
|
|
1331
|
+
Menu()
|
|
1332
|
+
|
|
1333
|
+
else:
|
|
1334
|
+
|
|
1335
|
+
enlist = []
|
|
1336
|
+
|
|
1337
|
+
cover_dict = {}
|
|
1338
|
+
|
|
1339
|
+
feed()
|
|
1340
|
+
|
|
1341
|
+
if not journal:
|
|
1342
|
+
print("Empty Journal!")
|
|
1343
|
+
feed()
|
|
1344
|
+
else:
|
|
1345
|
+
print("Journal Uploaded!")
|
|
1346
|
+
|
|
1347
|
+
print()
|
|
1348
|
+
|
|
1349
|
+
trackHEH = []
|
|
1350
|
+
|
|
1351
|
+
for x in journal:
|
|
1352
|
+
if x.isalpha() and x not in cover_dict:
|
|
1353
|
+
|
|
1354
|
+
cover = "".join(random.choices(
|
|
1355
|
+
string.ascii_letters + string.digits,
|
|
1356
|
+
k=6
|
|
1357
|
+
))
|
|
1358
|
+
|
|
1359
|
+
print()
|
|
1360
|
+
cover = cover + " "
|
|
1361
|
+
cover_dict[x] = cover
|
|
1362
|
+
enlist.append(cover)
|
|
1363
|
+
trackHEH.append(cover)
|
|
1364
|
+
|
|
1365
|
+
|
|
1366
|
+
elif x in cover_dict:
|
|
1367
|
+
cover = cover_dict[x]
|
|
1368
|
+
enlist.append(cover)
|
|
1369
|
+
trackHEH.append(cover)
|
|
1370
|
+
else:
|
|
1371
|
+
enlist.append(x)
|
|
1372
|
+
|
|
1373
|
+
print()
|
|
1374
|
+
print("Encrypting...")
|
|
1375
|
+
time.sleep(1)
|
|
1376
|
+
|
|
1377
|
+
journal_name = j_name
|
|
1378
|
+
|
|
1379
|
+
encryption_key = json.dumps(cover_dict)
|
|
1380
|
+
encryption_date = date.today()
|
|
1381
|
+
|
|
1382
|
+
cursor.execute(
|
|
1383
|
+
"""
|
|
1384
|
+
INSERT INTO journal_details
|
|
1385
|
+
(user_id, journal_name, encryption_key, encryption_date)
|
|
1386
|
+
VALUES (%s, %s, %s, %s)
|
|
1387
|
+
""",
|
|
1388
|
+
(user_id, journal_name, encryption_key, encryption_date))
|
|
1389
|
+
mycon.commit()
|
|
1390
|
+
|
|
1391
|
+
finalenlist = "".join(enlist)
|
|
1392
|
+
print()
|
|
1393
|
+
print("Successfully Encrypted!")
|
|
1394
|
+
print()
|
|
1395
|
+
print()
|
|
1396
|
+
time.sleep(1)
|
|
1397
|
+
clear()
|
|
1398
|
+
show_output("Here's your Encrypted text", finalenlist)
|
|
1399
|
+
print()
|
|
1400
|
+
print("Here's the Encryption Key : ")
|
|
1401
|
+
print(json.dumps(cover_dict))
|
|
1402
|
+
print()
|
|
1403
|
+
print("You'll be redirected to the a new page.")
|
|
1404
|
+
print()
|
|
1405
|
+
print()
|
|
1406
|
+
time.sleep(7)
|
|
1407
|
+
Menu()
|
|
1408
|
+
|
|
1409
|
+
|
|
1410
|
+
def banner():
|
|
1411
|
+
print('''
|
|
1412
|
+
██████╗ ██████╗ ██╗██╗ ██╗ ██████╗ ██╗ ██╗██████╗ ███╗ ██╗ █████╗ ██╗
|
|
1413
|
+
██╔══██╗██╔══██╗██║██║ ██║██╔═══██╗██║ ██║██╔══██╗████╗ ██║██╔══██╗██║
|
|
1414
|
+
██████╔╝██████╔╝██║██║ ██║██║ ██║██║ ██║██████╔╝██╔██╗ ██║███████║██║
|
|
1415
|
+
██╔═══╝ ██╔══██╗██║╚██╗ ██╔╝██║ ██║██║ ██║██╔══██╗██║╚██╗██║██╔══██║██║
|
|
1416
|
+
██║ ██║ ██║██║ ╚████╔╝ ╚██████╔╝╚██████╔╝██║ ██║██║ ╚████║██║ ██║███████╗
|
|
1417
|
+
╚═╝ ╚═╝ ╚═╝╚═╝ ╚═══╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═══╝╚═╝ ╚═╝╚══════╝=
|
|
1418
|
+
|
|
1419
|
+
Give your journals the privacy they deserve :)
|
|
1420
|
+
''')
|
|
1421
|
+
|
|
1422
|
+
if __name__ == "__main__":
|
|
1423
|
+
time.sleep(2)
|
|
1424
|
+
start()
|
|
1425
|
+
|
|
1426
|
+
cursor.close()
|
|
1427
|
+
mycon.close()
|
|
1428
|
+
|
|
1429
|
+
|