-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkeyfinder.py
74 lines (64 loc) · 2.43 KB
/
keyfinder.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
#!/usr/bin/python3
from PwdManager import PwdManager
import getpass
#import colorama # just for fun
#from colorama import Fore
def cli_menu(pmgr):
uname = input("Enter username: ")
while True:
print()
#print(Fore.BLUE + "1. List all accounts")
print("1. List all accounts")
print("2. Get the password for an account")
print("3. Add an account")
print("4. Change a password")
print("5. Delete an account")
print("6. Add user")
print("7. Delete user")
print("8. [Q]uit")
print()
choice = input("Select one: ")
if choice == "1":
pmgr.get_account_names(uname)
elif choice == "2":
pmgr.get_password(uname)
elif choice == "3":
account_name = input("What account password would you like to add? ")
pmgr.add_account(uname, account_name)
elif choice == "4":
account_name = input("What account password would you like to change? ")
if pmgr.change_account_password(uname, account_name):
print("Change successful")
else:
print("Change NOT successful")
elif choice == "5":
account_name = input("What account do you want to delete? ")
opt = input(f"Are you sure you want to delete {account_name} N/y? ").casefold()
if opt != "y":
print("Ok. We won't delete it.")
else:
if pmgr.delete_account(uname, account_name):
print(f"{account_name} deleted.")
else:
print(f"{account_name} NOT deleted.")
elif choice == "6":
user = input("Enter user name: ")
pwd = getpass.getpass("Password: ")
if pwd == getpass.getpass("Confirm: "):
print("adding ...")
pmgr.add_user_password(user,pwd)
elif choice == "7":
user = input("Enter user to be deleted: ")
pwd = getpass.getpass("Password: ")
pmgr.delete_user(user, pwd)
elif choice == "8" or "Q" or "q":
print("Thanks for stopping by.")
return True
else:
("Invalid selection. Try again")
def main():
#colorama.init()
pmgr = PwdManager()
cli_menu(pmgr)
if __name__ == '__main__':
main()