Skip to content

Commit 237707e

Browse files
committed
Added python file and README
1 parent 030e159 commit 237707e

2 files changed

Lines changed: 94 additions & 0 deletions

File tree

Password_Manager/README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<!--Please do not remove this part-->
2+
![Star Badge](https://img.shields.io/static/v1?label=%F0%9F%8C%9F&message=If%20Useful&style=style=flat&color=BC4E99)
3+
![Open Source Love](https://badges.frapsoft.com/os/v1/open-source.svg?v=103)
4+
5+
# PASSWORD MANAGER
6+
7+
## 🛠️ Description
8+
A password manager program that lets you store all youyr passwords for websites, with username and choice of password. You'll be getting editable option, you can add and remove passowrds of your choice to free up space. These passwords will be encrypted in CSV file. No need to worry! When you would want to see the password again this program will decrypt the file for you.
9+
10+
## ⚙️ Languages or Frameworks Used
11+
This project is created using python programming language.
12+
Modules : CSV, cryptography
13+
14+
## 🌟 How to run
15+
Running the script is really simple! Just open a terminal in the folder where your script is located and run the following commands: pip install cryptography
16+
17+
```sh
18+
pip install cryptography
19+
```
20+
21+
```sh
22+
python pass_mng.py
23+
```
24+
25+
26+
## 📺 Demo
27+
28+
## 🤖 Author
29+
[Dhruv Vyas](https://github.com/dhruvvyas951)
30+

Password_Manager/pass_mng.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import csv
2+
from cryptography.fernet import Fernet
3+
4+
passwords = []
5+
key = Fernet.generate_key()
6+
cipher_suite = Fernet(key)
7+
8+
def encrypt_password(password):
9+
return cipher_suite.encrypt(password.encode())
10+
11+
def decrypt_password(encrypted_password):
12+
return cipher_suite.decrypt(encrypted_password).decode()
13+
14+
def add_password():
15+
website = input("Website: ")
16+
username = input("Username: ")
17+
password = input("Password: ")
18+
encrypted_password = encrypt_password(password)
19+
passwords.append({
20+
"website": website,
21+
"username": username,
22+
"password": encrypted_password
23+
})
24+
with open('passwords.csv', mode='a', newline='') as file:
25+
writer = csv.writer(file)
26+
writer.writerow([website, username, encrypted_password])
27+
28+
def get_password(website):
29+
for entry in passwords:
30+
if entry["website"] == website:
31+
username = entry["username"]
32+
encrypted_password = entry["password"]
33+
decrypted_password = decrypt_password(encrypted_password)
34+
print(f"Website: {website}")
35+
print(f"Username: {username}")
36+
print(f"Password: {decrypted_password}")
37+
return
38+
print("Website not found")
39+
40+
with open('passwords.csv', mode='r') as file:
41+
reader = csv.reader(file)
42+
for row in reader:
43+
passwords.append({
44+
"website": row[0],
45+
"username": row[1],
46+
"password": row[2]
47+
})
48+
49+
while True:
50+
print("\n1. Add Password")
51+
print("2. Get Password")
52+
print("3. Exit")
53+
54+
choice = input("Enter your choice: ")
55+
56+
if choice == '1':
57+
add_password()
58+
elif choice == '2':
59+
website = input("Enter website: ")
60+
get_password(website)
61+
elif choice == '3':
62+
break
63+
else:
64+
print("Invalid choice")

0 commit comments

Comments
 (0)