-
Notifications
You must be signed in to change notification settings - Fork 0
/
interface.py
executable file
·188 lines (174 loc) · 7.1 KB
/
interface.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
#!/usr/bin/env python3.8
from passwordlock import User, Credentials
def function():
print("PASSWORD LOCKER")
function()
def create_new_user(username,password):
"""
Function to create a new user with a username and password
"""
new_user = User(username,password)
return new_user
def save_user(user):
"""
Function to save a new user
"""
return user.save_user()
def display_user():
"""
Function to display existing user
"""
return User.display_user()
def login_user(username,password):
"""
function that checks whether a user exist and then login the user in.
"""
check_user = Credentials.verify_user(username,password)
return check_user
def create_new_credential(account,userName,password):
"""
Function that creates new credentials for a given user account
"""
new_credential = Credentials(account,userName,password)
return new_credential
def save_credentials(credentials):
"""
Function to save Credentials to the credentials list
"""
return credentials. save_details()
def display_accounts_details():
"""
Function that returns all the saved credential.
"""
return Credentials.display_credentials()
def delete_credential(credentials):
"""
Function to delete a Credentials from credentials list
"""
return credentials.delete_credentials()
def find_credential(account):
"""
Function that finds a Credentials by an account name and returns the Credentials that belong to that account
"""
return Credentials.find_credential(account)
def check_credendtials(account):
"""
Function that check if a Credentials exists with that account name and return true or false
"""
return Credentials.if_credential_exist(account)
def generate_Password():
"""
generates a random password for the user.
"""
auto_password = Credentials.generatePassword(self= Credentials)
return auto_password
def copy_password(account):
"""
A function that copies the password using the pyperclip framework
We import the framework then declare a function that copies the emails.
"""
return Credentials.copy_password(account)
def passlocker():
print("Hello Welcome to your Accounts' Password Store...\n Please enter one of the following to proceed.\n CA --- Create New Account \n LI --- Have An Account \n")
short_code=input("").lower().strip()
if short_code == "ca":
print("Sign Up")
print('*' * 50)
username = input("User_name: ")
while True:
print(" TP - To type your own pasword:\n GP - To generate random Password")
password_Choice = input().lower().strip()
if password_Choice == 'tp':
password = input("Enter Password\n")
break
elif password_Choice == 'gp':
password = generate_Password()
break
else:
print("Invalid password please try again")
save_user(create_new_user(username,password))
print("*" * 85)
print(f"Hello {username}, Your account has been created succesfully! Your password is: {password}")
print("*" * 85)
elif short_code == "li":
print("*" * 50)
print("Enter your User name and your Password to log in:")
print('*' * 50)
username = input("User name: ")
password = input("password: ")
login = login_user(username,password)
if login_user == login:
print(f"Hello {username}.Welcome To PassWord Locker Manager")
print('\n')
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 randomn 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("." * 20)
print("Account name ....")
account = input().lower()
print("Your Account username")
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 Own Password\n")
break
elif password_Choice == 'gp':
password = generate_Password()
break
else:
print("Invalid password please try again")
save_credentials(create_new_credential(account,userName,password))
print('\n')
print(f"Account Credential for: {account} - UserName: {userName} - Password:{password} created succesfully!")
print('\n')
elif short_code == "dc":
if display_accounts_details():
print("Here's your list of accounts: ")
print('*' * 30)
print('_' * 30)
for account in display_accounts_details():
print(f" Account:{account.account} \n User Name:{username}\n Password:{password}")
print('_' * 30)
print('*' * 30)
else:
print("You don't have any credentials saved yet..........")
elif short_code == "fc":
print("Enter the Account Name you want to search for")
search_name = input().lower()
if find_credential(search_name):
search_credential = find_credential(search_name)
print(f"Account Name : {search_credential.account}")
print('-' * 50)
print(f"User Name: {search_credential.userName} Password :{search_credential.password}")
print('-' * 50)
else:
print("That Credential does not exist")
print('\n')
elif short_code == "d":
print("Enter the account name of the Credentials you want to delete")
search_name = input().lower()
if find_credential(search_name):
search_credential = find_credential(search_name)
print("_"*50)
search_credential.delete_credentials()
print('\n')
print(f"Your stored credentials for : {search_credential.account} successfully deleted!!!")
print('\n')
else:
print("That Credential you want to delete does not exist in your store yet")
elif short_code == 'gp':
password = generate_Password()
print(f" {password} Has been generated successfull. You can proceed to use it to your account")
elif short_code == 'ex':
print("Thanks for using passwords store manager.. See you next time!")
break
else:
print("Wrong entry... Check your entry again and let it match those in the menu")
else:
print("Please enter a valid input to continue")
if __name__ == '__main__':
passlocker()