Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
120 changes: 120 additions & 0 deletions PASSWORDMANAGE/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@

# 🔐 Password Manager

A secure desktop application to store and manage website credentials. It provides an intuitive UI, encrypted password storage, and basic CRUD functionality using SQLite and Python.

---

## 📌 Features

### ✅ Core Functionality
- **Master Password Login**: Access is protected with a configurable master password.
- **Add Records**: Securely add website credentials (website, username, password).
- **View Records**: Display all saved records in a sortable Treeview.
- **Update/Delete Records**: Modify or remove existing entries.
- **Copy Password**: Quickly copy passwords to clipboard with one click.
- **Encrypted Passwords**: Passwords are stored securely using `cryptography.Fernet`.
- **Masked Input**: Password entry fields are hidden by default.
- **Popup Notifications**: Temporary feedback for successful operations or errors.

---

## 📁 Project Structure

```plaintext
├── password manager.py # Main GUI application
├── db_operations.py # Handles database and encryption logic
├── secret.key # Auto-generated key for encrypting passwords
├── password_records.db # Local SQLite database (auto-created)
```

---

## 🔒 Security & Encryption

- Uses `cryptography.Fernet` for symmetric encryption (AES).
- A unique encryption key is generated and stored in `secret.key`.
- Only the password field is encrypted in the database.
- `secret.key` is critical; if lost, encrypted passwords become unrecoverable.

---

## 🛠 Setup Instructions

### 📦 Requirements
- Python 3.7 or higher
- Required Python packages:
```bash
pip install cryptography
```

### ▶ How to Run
```bash
python "password manager.py"
```

---

## 🔐 Master Password

The master password is **hardcoded** in the application for demonstration purposes.

- The default master password is:
```
admin123
```
- **To change** the master password, edit the following line in `password manager.py`:
```python
if entered_password == "admin123":
```

---

## 🚧 Planned Enhancements

- [ ] Implement search functionality for website/username
- [ ] Add master password change feature
- [ ] Include password strength meter
- [ ] Integrate a password generator
- [ ] Export/import database with encryption
- [ ] Toggle password visibility in entry field

---

## 🧪 Testing

You can test the current features by:
1. Running the application
2. Logging in using the master password (`admin123`)
3. Adding new records and verifying encryption by checking the `password_records.db`
4. Testing copy password and update/delete functionality

---

## 🧠 Usage Tips

- To reset encryption (for testing), delete the `secret.key` and `password_records.db` files.
⚠ **This will erase all stored data!**

- Keep `secret.key` safe and never share it. Losing this file means losing access to all encrypted passwords.

---

## 👨‍💻 Authors

Developed with Python by a security-conscious developer using:
- `tkinter` for GUI
- `sqlite3` for local storage
- `cryptography` for encryption

---

## ⚠ Disclaimer

This tool is intended for educational and personal use. For handling sensitive credentials, professional-grade tools (like Bitwarden or 1Password) are recommended.

---

## 📜 License

This project is licensed under the MIT License. See `LICENSE` for details.
Binary file not shown.
96 changes: 96 additions & 0 deletions PASSWORDMANAGE/db_operations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
import sqlite3
from cryptography.fernet import Fernet


class DbOperations:

def __init__(self):
self.key = self.load_key()
self.fernet = Fernet(self.key)

def load_key(self):
try:
with open("secret.key", "rb") as f:
return f.read()
except FileNotFoundError:
key = Fernet.generate_key()
with open("secret.key", "wb") as f:
f.write(key)
return key

def connect_to_db(self):
conn = sqlite3.connect('password_records.db')
return conn

def create_table(self, table_name="password_info"):
conn = self.connect_to_db()
query = f'''
CREATE TABLE IF NOT EXISTS {table_name} (
ID INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
created_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
update_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
website TEXT NOT NULL,
username VARCHAR(200),
password TEXT
);
'''
with conn as conn:
cursor = conn.cursor()
cursor.execute(query)

def create_record(self, data, table_name="password_info"):
website = data['website']
username = data['username']
password = self.fernet.encrypt(data['password'].encode()) #Encrypt password
conn = self.connect_to_db()
query = f'''
INSERT INTO {table_name} (website, username, password) VALUES (?, ?, ?);
'''
with conn as conn:
cursor = conn.cursor()
cursor.execute(query, (website, username, password))

def show_records(self, table_name="password_info"):
conn = self.connect_to_db()
query = f'''
SELECT * FROM {table_name};
'''
with conn as conn:
cursor = conn.cursor()
list_records = cursor.execute(query).fetchall()

decrypted_records = []
for row in list_records:
decrypted_password = self.fernet.decrypt(row[5]).decode()
# row: (ID, created_date, update_date, website, username, password)
decrypted_records.append((
row[0], # ID
row[1], # created_date
row[2], # update_date
row[3], # website
row[4], # username
decrypted_password # decrypted password
))
return decrypted_records

def update_record(self, data, table_name="password_info"):
ID = data['ID']
website = data['website']
username = data['username']
password = self.fernet.encrypt(data['password'].encode()) #Encrypt updated password
conn = self.connect_to_db()
query = f'''
UPDATE {table_name} SET website = ?, username = ?, password = ? WHERE ID = ?;
'''
with conn as conn:
cursor = conn.cursor()
cursor.execute(query, (website, username, password, ID))

def delete_record(self, ID, table_name="password_info"):
conn = self.connect_to_db()
query = f'''
DELETE FROM {table_name} WHERE ID = ?;
'''
with conn as conn:
cursor = conn.cursor()
cursor.execute(query, (ID,))
Loading