-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.py
More file actions
executable file
·192 lines (166 loc) · 7.17 KB
/
run.py
File metadata and controls
executable file
·192 lines (166 loc) · 7.17 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
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
#!/usr/bin/env python3.6
from user import User
from credentials import Credentials
def create_new_user(userName,userPassword):
'''
This is a function that creates a new user using a user name and a password
'''
new_user=User(userName,userPassword)
return new_user
def save_user(user):
'''
A function that saves the new user
'''
user.save_user()
def display_users(self):
'''
Function to display all the saved users in the user_list
'''
return User.display_users()
def login_user(userName, userPassword):
'''
Function to login new user only. Checks if the user had been logged in earlier and logs in if not yet.
'''
verify_user=Credentials.check_user(userName,userPassword)
return verify_user
def create_new_credential(account,userName,userPassword):
'''
Function that creates new user credentials for a particular account
'''
new_credential=Credentials(account,userName,userPassword)
return new_credential
def save_credentials(credentials):
'''
Function that saves the entered user account credentials
'''
credentials.save_credentials()
def display_credential_details():
'''
A function that displays all the details in our credentials
'''
return Credentials.display_credentials()
def delete_credential(credentials):
'''
A function that deletes particular selected credentials
'''
credentials.delete_credentials
def find_credentials(account):
'''
A function that searches for a saved credential using the account name
'''
return Credentials.find_credentials(account)
def check_credential(account):
'''
Function to check credential already exist in the credential_list, returns a boolean
'''
return Credentials.credential_exist(account)
def generatePassword():
'''
Function that generates random passwords for the user account
'''
auto_generate_password=Credentials.systemGeneratedPassword()
return auto_generate_password
def copy_credential(account):
'''
A function that copies credentials using the pyperclip framework.
We import the framework then declare a function that copies the credentials
'''
return Credentials.copy_credentials(account)
def passwordManager():
print("I would like to know your name please.")
user=input()
print(f"Hello {user} I am happy to be your one place store for all your passwords")
print("Use any of the following to proceed\n CA...Create New Account. \n LI...Login to your account.")
short_code=input(" ").lower().strip()
if short_code=="ca":
print("Sign Up")
print("*"*10)
userName=input("user_name: ")
while True:
print("TP...To type your own password \n GP...If you want the system to generate a random password for you.")
password_choice=input().lower().strip()
if password_choice=="tp":
password=input("Enter your password: ")
break
elif password_choice=="gp":
password=generatePassword()
break
else:
print("You must either input your own password or allow the system to generate it for you by just typing gp")
save_user(create_new_user(userName,password))
print("."*10)
print(f"{userName}, your account has been created successfully!!! and {password} is the password that the system has generated for you.")
print("."*10)
elif short_code=="li":
print("*"*10)
print("Enter you user name and password to login: ")
print("."*10)
userName=input("Type your user name: ")
password=input("Password: ")
login=login_user(userName,password)
if login_user == login:
print(f"{userName} there you are! Welcome to your password locker manager")
while True:
print("Use these short codes:\n CC - Create a new credential \n DC - Display Credentials \n FC - Find a credential \n GP - Generate A random password \n D - Delete credential \n EX - Exit the application \n")
short_code = input().lower().strip()
if short_code=="cc":
print("Create New Credential")
print(".."*5)
print("Your account name...")
account=input().lower()
print("Your account user name")
userName=input()
while True:
print(" TP - To type your own pasword if you already have an account:\n GP - To generate random Password")
password_Choice = input().lower().strip()
if password_Choice == 'tp':
password = input("Enter Your Password\n")
break
elif password_Choice == 'gp':
password = generatePassword()
break
else:
print("You must either enter your own password or gp to allow the system to create it for you.")
save_credentials(create_new_credential(account,userName,password))
print(f"The account credentials of {account} account, with {userName} and a password of {password} have been created successfully.")
elif short_code=="dc":
if display_credential_details():
print("Here is your list of account")
print("-"*10)
for account in display_credential_details():
print(f"Account:{account.account} \n user_name: {userName} \n password: {password}")
print("-"*10)
else:
print("There are no credentials yet.")
elif short_code=="fc":
print("Enter the account name of the of the credentials you wish to search")
search_account=input().lower()
if find_credentials(search_account):
search_credential=find_credentials(search_account)
print(f"Account Name : {search_credential.account}")
print('-' * 10)
print(f"User name: {search_credential.userName} \n password: {search_credential.password}")
print("."*10)
else:
print("We couldn't find your credentials.")
print("\n")
elif short_code=="d":
print("Enter the account name of the credential you wish to delete.")
print("\n")
search_name = input().lower()
if find_credentials(search_name):
search_credential = find_credentials(search_name)
print("_"*50)
search_credential.delete_credentials()
print('\n')
print(f"Your saved credentials for : {search_credential.account} successfully deleted!!!")
print('\n')
else:
print("That Credential you want to delete does not exist in the credentials_list.")
elif short_code == 'ex':
print("Thank you for visiting your passwords store manager. Have a great day!")
break
else:
print("Wrong entry.The short code entered doesn't match the ones provided. Try again.")
if __name__ == '__main__':
passwordManager()