-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpassword_manager.py
More file actions
30 lines (23 loc) · 824 Bytes
/
Copy pathpassword_manager.py
File metadata and controls
30 lines (23 loc) · 824 Bytes
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
'''This is a programme that demonstrates a password managing programme. The user can create a password file, and add or view passwords'''
def view():
with open("passwords.txt", "r") as f:
for line in f.readlines():
data = line.rstrip()
user, passw = data.split("|")
print("User:", user, "| Password:", passw)
def add():
name = input("Account Name: ")
pwd = input("Password: ")
with open("passwords.txt", "a") as f:
f.write(name + "|" + pwd + "\n")
while True:
mode = input("Would you like to add a new password or view the existing ones? (view/add), press q to quit: ").lower()
if mode == "q":
break
if mode == "view":
view()
elif mode == "add":
add()
else:
print("Invalid mode.")
continue