-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsecret_diary.py
More file actions
53 lines (48 loc) · 1.19 KB
/
Copy pathsecret_diary.py
File metadata and controls
53 lines (48 loc) · 1.19 KB
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
from replit import db
import datetime, os, time, random
def addEntry():
time.sleep(1)
os.system("clear")
timestamp = datetime.datetime.now()
print(f"Diary entry for {timestamp}")
print()
entry = input("> ")
db[timestamp] = entry
def viewEntry():
keys = db.prefix("2")
for key in keys:
time.sleep(1)
os.system("clear")
print(f"""{key}
{db[key]}""")
print()
opt = input("Next or exit? > ")
if(opt.lower()[0]=="e"):
break
keys = db.keys()
if len(keys)<1:
print("First Run > Create account")
username = input("Username > ")
password = input("Password > ")
salt = random.randint(0,9999999)
newPassword = hash(f"{password}{salt}")
db[username] = {"password": newPassword, "salt": salt}
else:
print("Log in")
username = input("Username > ")
password = input("Password > ")
if username not in keys:
print("Username or password incorrect")
exit()
salt = db[username]["salt"]
newPassword = hash(f"{password}{salt}")
if db[username]["password"]!=newPassword:
print("Username or password incorrect")
exit()
while True:
os.system("clear")
menu = input("1: Add\n2: View\n> ")
if menu == "1":
addEntry()
else:
viewEntry()