CS Project
CS Project
PASSWORD MANAGER
SUBMITTED BY:
HASSAN SHABBIR
12 G
GULF MODEL SCHOOL
INDEX
1. Acknowledgement
2. Requirements
3. Introduction
4. About Project
5. Source Code
6. Output
7. Suggestions for Improvement
8. Bibliography
REQUIREMENTS
To ensure smooth functioning of your Python-based Password Manager application, the
following system requirements must be met:
1.Operating System Requirements
The application is compatible with the following operating systems:
● Windows: Version 7 or higher (Windows 10 or later recommended).
● Linux: Any modern distribution with Python 3.7+ support (e.g., Ubuntu, Fedora,
Debian).
● macOS: Version 10.14 (Mojave) or higher.
2.Hardware Requirements
To run the application efficiently, your system should meet these minimum specifications:
● Processor: Dual-core processor (2 GHz or higher recommended).
● RAM: Minimum 2 GB (4 GB or more recommended for better performance).
● Storage: At least 500 MB of free disk space for the application and database.
● Display: Minimum resolution of 1024x768 pixels for optimal GUI display.
3.Software Requirements
The following software and dependencies are required:
● Python: Version 3.7 or higher.
● Python Libraries Required:
○ tkinter (for the graphical user interface).
○ mysql-connector (for MySQL integration).
○ hashlib (for data encryption).
○ pyperclip (for clipboard operations).
4.User Account Privileges
● Installation: Administrative privileges may be required to install Python, Server, and
related libraries.
INTRODUCTION
In today’s highly digitalized world, the role of passwords in our daily lives cannot be overstated.
The struggle to remember numerous unique passwords often results in individuals adopting
unsafe practices, such as reusing the same password across multiple accounts or creating weak
passwords that are easy to guess, increasing the risk of cyberattacks and data breaches.
To mitigate these risks and provide a reliable solution to the challenges of password
management, this project focuses on the development of a secure and user-centric password
manager application. And to offer users a centralized, secure, and convenient platform for
storing, and managing their passwords efficiently. The password manager application is
designed with a range of essential features These features include:
To make password management accessible for all users, the application features an
intuitive graphical user interface (GUI). This interface simplifies common tasks such as adding
new passwords and retrieving saved information.
4.Ability to Add And View All Detailed Credential Information:
Users can input detailed information for each password entry, including website URLs,
usernames. This structured data storage not only enhances organization but also
makes it easier for users to locate specific credentials quickly when needed.
Purpose: Provides a GUI (Graphical User Interface) framework for Python applications.
Functions Used:
messagebox: Displays pop-up messages for user feedback (e.g., errors, information).
2.cryptography.fernet
Functions Used:
3.json
Functions Used:
4.os
Objective
This project aims to develop a secure and user-friendly password manager application to
address key challenges in password management:
1.Enhance Password Security: Provide a platform to create, store, and manage strong,
unique passwords, mitigating risks from weak or reused credentials.
3.Enhance User Experience: Offer an intuitive, user-friendly interface suitable for users
of all technical backgrounds.
Scope
The project focuses on building a desktop application with the following features:
1.Core Functionalities:
● Password Storage: Secure storage of usernames, passwords, and website URLs
with encryption.
● User Interface: Intuitive GUI for easy navigation and password retrieval.
2.Technical Aspects:
● Language: Development in Python.
● Encryption: Robust algorithms like AES to protect user data.
3.User Interaction:
● Interface Design: Accessible and visually appealing GUI.
● User Experience: Simplified, intuitive workflows for ease of use.
The application aims to provide a secure, efficient, and user-friendly solution to
modern password management challenges.
SOURCE CODE
1. import tkinter as tk
2. from tkinter import messagebox
3. from cryptography.fernet import Fernet
4. import json
5. import os
6.
7. # Master key setup (for simplicity, stored in code, should ideally be stored securely)
8. MASTER_KEY = "Dub@i007"
9.
10. # File to store encryption key and encrypted data
11. key_file = 'encryption.key'
12. data_file = 'passwords.json'
13.
14. # Load or generate encryption key
15. def load_encryption_key():
16. if os.path.exists(key_file):
17. with open(key_file, 'rb') as file:
18. return file.read()
19. else:
20. key = Fernet.generate_key()
21. with open(key_file, 'wb') as file:
22. file.write(key)
23. return key
24.
25. ENCRYPTION_KEY = load_encryption_key()
26. cipher = Fernet(ENCRYPTION_KEY)
27.
28. # Load and save encrypted data
29. def load_data():
30. if not os.path.exists(data_file):
31. return {}
32. with open(data_file, 'r') as file:
33. encrypted_data = file.read()
34. if encrypted_data:
35. decrypted_data =
cipher.decrypt(encrypted_data.encode()).decode()
36. return json.loads(decrypted_data)
37. return {}
38.
39. def save_data(data):
40. with open(data_file, 'w') as file:
41. encrypted_data =
cipher.encrypt(json.dumps(data).encode()).decode()
42. file.write(encrypted_data)
43.
44. data = load_data()
45.
46. def verify_master_key(input_key):
47. return input_key == MASTER_KEY
48.
49. def add_entry(username, url, password):
50. if not username or not url:
51. messagebox.showerror("Error", "Please enter Username or URL!")
52. return
53. if not password:
54. messagebox.showerror("Error", "Password cannot be empty!")
55. return
56. if url not in data:
57. data[url] = []
58. data[url].append({"username": username, "password": password})
59. save_data(data)
60. messagebox.showinfo("Success", "Password added successfully!")
61.
62. def delete_entry(url, username):
6 i url in data:
3. f
6 entries = data[url]
4.
6 for entry in entries:
5.
6 if entry["username"] == username:
6.
6 entries.remove(entry)
7.
6 if not entries:
8.
69. del data[url]
70. save_data(data)
71. messagebox.showinfo("Success", "Entry deleted
successfully!")
72. return
73. messagebox.showerror("Error", "Username not found for the given URL!")
74. else:
75. messagebox.showerror("Error", "URL not found!")
76.
77. def get_entry(url):
78. if url in data:
79. entries = data[url]
80. message = "\n".join([f"Username: {entry['username']}\nPassword:
{entry['password']}" for entry in entries])
81. messagebox.showinfo("Password Entries", message)
82. else:
83. messagebox.showerror("Error", "URL not found!")
84.
85. def init_app():
8 d authenticate():
6. ef
8 if verify_master_key(master_key_entry.get()):
7.
8 master_window.destroy()
8.
8 main_app()
9.
9 else:
0.
91. messagebox.showerror("Error", "Invalid master key!")
92.
93. master_window = tk.Tk()
94. master_window.title("Password Manager - Authentication")
95.
96. tk.Label(master_window, text="Enter Master Key:").pack(pady=10)
97. master_key_entry = tk.Entry(master_window, show="*", width=30)
98. master_key_entry.pack(pady=10)
99.
100. tk.Button(master_window, text="Submit",
command=authenticate).pack(pady=10)
101.
102. master_window.mainloop()
103.
104. def main_app():
105. def handle_add():
106. add_entry(username_entry.get(), url_entry.get(),
password_entry.get())
108. def handle_delete():
109. delete_url = url_entry.get()
110. delete_username = username_entry.get()
111. if not delete_url or not delete_username:
112. messagebox.showerror("Error", "Enter the URL and Username to delete!")
113. else:
114. delete_entry(delete_url, delete_username)
115.
120.
121. get_entry(get_url)
122.
123. app = tk.Tk()
124. app.title("Password Manager")
125.
126. tk.Label(app, text="Username:").grid(row=0, column=0, padx=10, pady=5)
127. username_entry = tk.Entry(app, width=30)
128. username_entry.grid(row=0, column=1, padx=10, pady=5)
129.
130. tk.Label(app, text="URL:").grid(row=1, column=0, padx=10, pady=5)
131. url_entry = tk.Entry(app, width=30)
132. url_entry.grid(row=1, column=1, padx=10, pady=5)
133.
134. tk.Label(app, text="Password:").grid(row=2, column=0, padx=10, pady=5)
135. password_entry = tk.Entry(app, show="*", width=30)
136. password_entry.grid(row=2, column=1, padx=10, pady=5)
137.
138. tk.Button(app, text="Add", command=handle_add).grid(row=3, column=0,
padx=10, pady=10)
139. tk.Button(app, text="Delete", command=handle_delete).grid(row=3,
column=1, padx=10, pady=10)
140. tk.Button(app, text="Get", command=handle_get).grid(row=3, column=2, padx=10,
pady=10)
142 app.mainloop(
)
.
143 if name == " main ":
. init_app()
OUTPUT
SUGGESTIONS FOR IMPROVEMENT
● Avoid hardcoding the master key in the script. Store it securely in an environment
variable or a credential management tool (e.g., AWS Secrets Manager, Azure Key Vault).
This significantly reduces the risk of unauthorized access.
● Check for duplicate username-password pairs before adding a new entry to avoid
unnecessary redundancy and ensure data integrity.
● Lock the application after a certain number of incorrect master key attempts to
protect against brute-force attacks.
● Provide clear and detailed error messages (e.g., "File not found, restoring from
backup.") to guide users effectively.
● Improve the GUI with modern frameworks or designs for a better user interface and
ease of use