├── README.md └── passwordmanager.py /README.md: -------------------------------------------------------------------------------- 1 | # Password Manager Readme 2 | 3 | --- 4 | 5 | ## Overview: 6 | This Password Manager is a simple GUI application built using Python and Tkinter. It allows users to securely store and retrieve passwords for different websites along with their usernames. The passwords are encrypted using the Fernet symmetric encryption algorithm from the cryptography library. 7 | 8 | --- 9 | 10 | ## Features: 11 | 1. **Secure Encryption:** Passwords are encrypted using Fernet encryption with a key derived from the user's master password. This ensures that stored passwords remain secure. 12 | 2. **User-Friendly Interface:** The GUI interface makes it easy for users to enter and retrieve passwords without needing to remember them manually. 13 | 3. **Local Storage:** Encrypted passwords are stored locally in memory during the session, ensuring data privacy. 14 | 4. **Password Retrieval:** Users can retrieve their stored passwords by entering the website and username associated with the password. 15 | 16 | --- 17 | 18 | ## Dependencies: 19 | 1. Python 3.12.2 20 | 2. Tkinter (standard Python library for GUI) 21 | 3. cryptography library (install using `pip install cryptography`) 22 | 23 | --- 24 | 25 | ## How to Use: 26 | 1. Run the script `password_manager.py`. 27 | 2. Enter your master password in the provided field and click "Submit." 28 | 3. Once authenticated, the main Password Manager window will appear. 29 | 4. Enter the website, username, and password in the respective fields. 30 | 5. Click "Save Password" to encrypt and save the password locally. 31 | 6. To retrieve a password, enter the website and username and click "Retrieve Password." 32 | 33 | --- 34 | 35 | ## Important Notes: 36 | 1. **Master Password:** The security of your passwords depends on the strength of your master password. Choose a strong and unique master password. 37 | 2. **Security Concerns:** While this application provides local encryption, ensure your system is secure and free from malware or unauthorized access. 38 | 3. **Backup:** Consider backing up your encrypted password storage file periodically to avoid data loss. 39 | 4. **Customization:** You can modify the password storage logic (`get_encrypted_password` and `save_encrypted_password` functions) to integrate with a database or secure storage solution. 40 | 41 | --- 42 | 43 | ## Disclaimer: 44 | This Password Manager is for educational purposes and may not provide the same level of security as professional password management tools. Use it at your own risk and ensure compliance with applicable laws and regulations regarding data protection and privacy. 45 | 46 | --- 47 | 48 | ## Credits: 49 | - Developed by Asmit Bhatt 50 | - Created using Python, Tkinter, and the cryptography library. 51 | 52 | --- 53 | 54 | Feel free to customize and enhance the Password Manager according to your needs. For any questions or feedback, contact bhattasmit25@gmail.com 55 | 56 | --- 57 | -------------------------------------------------------------------------------- /passwordmanager.py: -------------------------------------------------------------------------------- 1 | from tkinter import * 2 | from tkinter import messagebox 3 | from cryptography.fernet import Fernet 4 | from cryptography.hazmat.primitives.kdf.scrypt import Scrypt 5 | import base64 6 | import os 7 | 8 | # Function to simulate retrieving encrypted passwords (replace with your actual logic) 9 | def get_encrypted_password(website, username): 10 | password_data = { 11 | ("example.com", "user1"): b'gAAAAABgCXWDZEDVQso0cb1oGMjFVcW6ZKrDe...', 12 | ("example.com", "user2"): b'gAAAAABgCXWDZEDVQso0cb1oGMjFVcW6ZKrDe...', 13 | } 14 | return password_data.get((website, username)) 15 | 16 | # Function to simulate saving encrypted passwords (replace with your actual logic) 17 | def save_encrypted_password(website, username, encrypted_password): 18 | password_data = { 19 | ("example.com", "user1"): b'gAAAAABgCXWDZEDVQso0cb1oGMjFVcW6ZKrDe...', 20 | ("example.com", "user2"): b'gAAAAABgCXWDZEDVQso0cb1oGMjFVcW6ZKrDe...', 21 | } 22 | password_data[(website, username)] = encrypted_password 23 | 24 | class PasswordManager: 25 | def _init_(self, master_password): 26 | self.master_password = master_password 27 | self.salt = os.urandom(16) # Generate a random salt for key derivation 28 | 29 | def derive_key(self): 30 | kdf = Scrypt( 31 | salt=self.salt, 32 | length=32, 33 | n=2**14, # Number of iterations (adjust as needed for security) 34 | r=8, 35 | p=1 36 | ) 37 | return base64.urlsafe_b64encode(kdf.derive(self.master_password.encode())) 38 | 39 | def encrypt_password(self, password): 40 | key = self.derive_key() 41 | fernet = Fernet(key) 42 | encrypted_password = fernet.encrypt(password.encode()) 43 | return encrypted_password 44 | 45 | def decrypt_password(self, encrypted_password): 46 | key = self.derive_key() 47 | fernet = Fernet(key) 48 | decrypted_password = fernet.decrypt(encrypted_password).decode() 49 | return decrypted_password 50 | 51 | class PasswordManagerUI: 52 | def _init_(self, root): 53 | self.root = root 54 | self.root.title("Password Manager") 55 | 56 | self.master_password_label = Label(self.root, text="Enter Master Password:") 57 | self.master_password_label.pack() 58 | 59 | self.master_password_entry = Entry(self.root, show="*") 60 | self.master_password_entry.pack() 61 | 62 | self.submit_button = Button(self.root, text="Submit", command=self.submit_master_password) 63 | self.submit_button.pack() 64 | 65 | # Initialize local password storage (dictionary) 66 | self.password_storage = {} 67 | 68 | def submit_master_password(self): 69 | master_password = self.master_password_entry.get() 70 | if not master_password: 71 | messagebox.showerror("Error", "Please enter a master password.") 72 | return 73 | 74 | self.password_manager = PasswordManager(master_password) 75 | 76 | self.root.destroy() 77 | self.show_password_manager_ui() 78 | 79 | def show_password_manager_ui(self): 80 | self.main_window = Tk() 81 | self.main_window.title("Password Manager") 82 | 83 | # Set the size of the main window 84 | window_width = 800 85 | window_height = 600 86 | screen_width = self.main_window.winfo_screenwidth() 87 | screen_height = self.main_window.winfo_screenheight() 88 | x_coordinate = (screen_width - window_width) // 2 89 | y_coordinate = (screen_height - window_height) // 2 90 | self.main_window.geometry(f"{window_width}x{window_height}+{x_coordinate}+{y_coordinate}") 91 | 92 | self.website_label = Label(self.main_window, text="Website:") 93 | self.website_label.pack() 94 | 95 | self.website_entry = Entry(self.main_window) 96 | self.website_entry.pack() 97 | 98 | self.username_label = Label(self.main_window, text="Username:") 99 | self.username_label.pack() 100 | 101 | self.username_entry = Entry(self.main_window) 102 | self.username_entry.pack() 103 | 104 | self.password_label = Label(self.main_window, text="Password:") 105 | self.password_label.pack() 106 | 107 | self.password_entry = Entry(self.main_window, show="*") 108 | self.password_entry.pack() 109 | 110 | self.save_button = Button(self.main_window, text="Save Password", command=self.save_password) 111 | self.save_button.pack() 112 | 113 | self.retrieve_button = Button(self.main_window, text="Retrieve Password", command=self.retrieve_password) 114 | self.retrieve_button.pack() 115 | 116 | def save_password(self): 117 | website = self.website_entry.get() 118 | username = self.username_entry.get() 119 | password = self.password_entry.get() 120 | 121 | if not website or not username or not password: 122 | messagebox.showerror("Error", "Please fill in all fields.") 123 | return 124 | 125 | encrypted_password = self.password_manager.encrypt_password(password) 126 | # Save encrypted password locally 127 | self.password_storage[(website, username)] = encrypted_password 128 | messagebox.showinfo("Success", "Password saved successfully.") 129 | 130 | def retrieve_password(self): 131 | website = self.website_entry.get() 132 | username = self.username_entry.get() 133 | 134 | if not website or not username: 135 | messagebox.showerror("Error", "Please fill in Website and Username fields.") 136 | return 137 | 138 | encrypted_password = self.password_storage.get((website, username)) 139 | 140 | if encrypted_password: 141 | decrypted_password = self.password_manager.decrypt_password(encrypted_password) 142 | messagebox.showinfo("Password", f"Decrypted Password: {decrypted_password}") 143 | else: 144 | messagebox.showerror("Error", "Password not found for the given Website and Username.") 145 | 146 | if _name_ == "_main_": 147 | root = Tk() 148 | app = PasswordManagerUI(root) 149 | root.mainloop() 150 | --------------------------------------------------------------------------------