-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.py
174 lines (144 loc) · 6.76 KB
/
run.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
#!
from user import User, Credentials
def create_new_user(username,password):
new_user = User(username,password)
return new_user
def save_user(user):
user.save_user()
def display_user():
return User.display_user()
def login_user(username,password):
check_user = Credentials.verify_user(username,password)
return check_user
def create_new_credential(account,userName,password):
new_credential = Credentials(account,userName,password)
return new_credential
def save_accounts(credentials):
credentials. save_details()
def display_accounts_details():
return Credentials.display_accounts()
def delete_credential(credentials):
credentials.delete_accounts()
def find_credential(account):
return Credentials.find_credential(account)
def check_credendtials(account):
return Credentials.if_credential_exist(account)
def generate_Password():
auto_password=Credentials.generatePassword()
return auto_password
def copy_password(account):
return Credentials.copy_password(account)
def passlocker():
print("----------------------------------------------------------------")
print("| WELCOME TO PASSWORD BANK |")
print("----------------------------------------------------------------")
print('\n')
print("Don't Know about you, but I've personally ran out of password memory...")
print('\n')
print("**That's where Pass Bank comes in!**")
print('\n')
print('\n')
print("1. Sign Up for new account ---> SU \n2. Sign In tp your account ---> SI \n")
choice=input("").lower().strip()
if choice == "su":
print("Sign Up")
print("----------------------------------------------------------------")
username = input("Preferred username: ")
while True:
print("Reply with: \nE -> Enter your own pasword: \nG -> To generate a Password: ")
password_Choice = input().lower().strip()
if password_Choice == 'e':
password = input("Enter Password\n")
break
elif password_Choice == 'g':
password = generate_Password()
break
else:
print("Invalid password")
save_user(create_new_user(username,password))
print("-----------------------------------------------------------------------------")
print(f"Dear, {username}! Congratulations, account has been created successfully!")
print("------------------------------------------------------------------------------")
elif choice == "si":
print("----------------------------------------------------------------")
print("Enter your details to log in:")
print("----------------------------------------------------------------")
username = input("Enter your: ")
password = input("Enter yourpassword: ")
login = login_user(username,password)
if login_user == login:
print("----------------------------------------------------------------")
print(" Sign In successful!")
print("----------------------------------------------------------------")
print('\n')
while True:
print("To get started, reply with:\nCreate a new credential --> CC \nView Credentials --> VC \nSearch Credential --> SC \nGenerate password --> G \nDelete --> D \nExit the application --> E \n")
choice = input().lower().strip()
if choice == "cc":
print("Add Credential")
print("----------------------------------------------------------------")
print("Account name: ")
account = input().lower()
print("Account username: ")
userName = input()
while True:
print("Reply with: \nT - To enter your own pasword:\nG - To generate random Password")
password_Choice = input().lower().strip()
if password_Choice == 't':
password = input("Enter Your Own Password\n")
break
elif password_Choice == 'g':
password = generate_Password()
break
else:
print("Invalid password please try again")
save_accounts(create_new_credential(account,userName,password))
print('\n')
print(f"Account Credential for: {account} - UserName: {userName} - Password:{password} created successfully")
print('\n')
elif choice == "vc":
if display_accounts_details():
print("Here's your list of accounts: ")
print("----------------------------------------------------------------")
for account in display_accounts_details():
print(f" Account:{account.account} \nUser Name:{username}\nPassword:{password}")
print("----------------------------------------------------------------")
else:
print("You don't have any credentials saved yet..........")
elif choice == "sc":
print("Enter the Account Name: ")
print("----------------------------------------------------------------")
search_name = input().lower()
if find_credential(search_name):
search_credential = find_credential(search_name)
print(f"Account Name : {search_credential.account}")
print("----------------------------------------------------------------")
print(f"Username: {search_credential.userName} Password :{search_credential.password}")
print("----------------------------------------------------------------")
else:
print("Credential couldn't be found")
print('\n')
elif choice == "d":
print("Enter the account name to proceed")
search_name = input().lower()
if find_credential(search_name):
search_credential = find_credential(search_name)
print("----------------------------------------------------------------")
search_credential.delete_accounts()
print('\n')
print(f" {search_credential.account} successfully deleted!!!")
print('\n')
else:
print("Failed: Credential not found")
elif choice == 'g':
password = generate_Password()
print(f"Generated Password: {password}")
elif choice == 'ex':
print("Exiting password bank...")
break
else:
print("Invalid entry")
else:
print("Enter a valid input")
if __name__ == '__main__':
passlocker()