forked from kal179/Beginners_Python_Examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHandlepassword.py
More file actions
63 lines (54 loc) · 1.76 KB
/
Handlepassword.py
File metadata and controls
63 lines (54 loc) · 1.76 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
54
55
56
57
58
59
60
61
62
63
# don't forget to add a sqlite3 db support
# and also add password encryption and decryption support
# Universal dict for saving passwords
passwords = {}
def addPassword():
getMoreSite = str(input('Name of Website : '))
getMorePassword = str(input('Password : '))
passwords[getMoreSite] = getMorePassword
def showPassword():
getName = str(input('Name of Website : '))
try:
return(getName + ' : ' + str(passwords[getName]))
except KeyError:
print('Password not saved')
def deletePassword():
toDelete = str(input('Website of Password to delete : '))
try:
del passwords[toDelete]
return('Deleted Successfully.')
except KeyError:
print('Invalid site to delete')
def showAll():
return(passwords)
def showWebsites():
keys = str(passwords.keys())
return(keys[9:])
def mainCode(add , view , remove , allwords , allSites):
while(True):
start = str(input('Add or View or Delete or Show all or Show sites : '))
if start.strip() == 'Add':
print(add())
continue
elif start.strip() == 'View':
print(view())
continue
elif start.strip() == 'Delete':
print(remove())
continue
elif start.strip() == 'Show all':
print(allwords())
continue
elif start.strip() == 'Show sites':
print(allSites())
continue
else:
quit()
# Main code
# Login function
login = str(input('Username : '))
loginPassword = str(input('Password : '))
if login == 'Kalpak' and loginPassword == 'thisisapassword': # replace with your username or password
print(mainCode(addPassword , showPassword , deletePassword , showAll , showWebsites))
else :
quit()