-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
43 lines (37 loc) · 1.22 KB
/
main.py
File metadata and controls
43 lines (37 loc) · 1.22 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
import pyperclip
import os
FILE_NAME = "passwords.txt"
def save_password():
website = input("Enter website name : ")
password = input("Enter password : ")
with open(FILE_NAME, "a") as f:
f.write(f"{website} <||> {password}\n") #delimiter: separates our website and password (here, delimiter = <||> (unique character))
def get_password():
website = input("Enter website : ")
with open(FILE_NAME, "r") as f:
for line in f:
if website in line:
password = line.strip().split("<||>")[1]
pyperclip.copy(password)
print("Password copied to clipboard!")
print(f"Password for {website} : {password}\n")
# print(line)
break
else:
print("Website not found! :(")
def main():
while True:
print("1. Save password")
print("2. Get password")
print("3. Exit")
choice = input("Choose an option : ")
if choice == '1':
save_password()
elif choice == '2':
get_password()
elif choice == '3':
print("Exiting...")
break
else:
print("Invalid Choice! Please try again.")
main()