From 62bb10e374455799f9f90da913cfeee0a5a3683e Mon Sep 17 00:00:00 2001 From: Hakaluka Date: Tue, 17 Dec 2024 01:21:17 +0530 Subject: [PATCH 1/6] Update README.md --- README.md | 149 +++++------------------------------------------------- 1 file changed, 12 insertions(+), 137 deletions(-) diff --git a/README.md b/README.md index 00acea3..cedc0d5 100644 --- a/README.md +++ b/README.md @@ -1,140 +1,15 @@ -# Password Manager for MergeFest Event +#Related Issue +Closes #38 -A **CLI-based password manager** built in Python for secure password storage and management. +##Type of Change + New Feature +##Description of Change +Allows you to organise the passwords better by providing a hierarchical password storage in the file. ---- -## Project Structure - -``` -/ -├── main.py # Entry point for executing the program -├── manager.py # Core logic and functionality -``` - ---- - -## Built With - -- **Python**: A versatile programming language. - ---- - -## Resources to Learn Python - -- [Python Tutorial - W3Schools](https://www.w3schools.com/python/) - ---- - -## Contributing - -Before contributing, review the following: - -1. **Rules for MergeFest**: [MergeFest Rules](https://github.com/IMGIITRoorkee/MergeFest-Hacker/blob/main/RULES.md) -2. **Contribution Guidelines**: [How to Contribute](https://github.com/IMGIITRoorkee/MergeFest-Hacker/blob/main/CONTRIBUTORS.md) - -### Contribution Guidelines - -- **Code Style**: Follow best practices for Python coding. -- **Readable Commits**: Write clear and descriptive commit messages. -- **Testing**: Ensure your changes don’t break existing functionality. -- **Proof of Work**: Attach a video showcasing the feature you implemented. - -### Looking for Guidance? - -Join our **Discord server**: [MergeFest Discord](https://discord.gg/aKaEbaVYKf) -Visit the **python** channel and ping `2Y` for assistance. - ---- - -## Setup Instructions - -1. **Fork the Repository** and clone it to your local machine: - ```bash - git clone - cd - ``` - -2. **Set up SSH** for GitHub to commit changes. - -3. **Ensure Python 3 is installed**: - ```bash - python3 --version - ``` - -4. **Install required dependencies**: - ```bash - pip install cryptography - ``` - -5. **Run the Application**: - ```bash - python3 main.py - ``` - ---- - -## Features - -- **Encrypt and Store Passwords**: Securely save your credentials. -- **Key Management**: Generate and load encryption keys. -- **File-Based Storage**: Organize passwords in a file. - ---- - -## Requirements - -- **Python**: Version 3.x or higher. -- **Library**: `cryptography` - ---- - -## How to Use - -1. **Start the Program**: - ```bash - python3 main.py - ``` - -2. **Menu Options**: - - `1`: Create a new encryption key. - - `2`: Load an existing encryption key. - - `3`: Create a new password file. - - `4`: Load an existing password file. - - `5`: Add a new password to the file. - - `6`: Retrieve a password from the file. - - `q`: Quit the application. - ---- - -## Example Usage - -### Create a New Key - -```bash -Enter choice: 1 -Enter key file path: keyfile.key -``` - -### Add a New Password - -```bash -Enter choice: 5 -Enter site: github -Enter password: securepassword123 -``` - -### Retrieve a Password - -```bash -Enter choice: 6 -Enter site: github -Password for github is securepassword123 -``` - ---- - -## Security Note - -- **Keep Your Encryption Key Safe**: - The encryption key is crucial for accessing your passwords. Losing it means your passwords cannot be decrypted. +##Implementation Details +Now you can create folder to divide your passwords into groups like lets say you make a folder named "google" for passwords of g-mail accounts, and "Microsoft" for microsoft accounts. +it allows to add passwords in any folder present in the password file. +Demo +Provide screenshots or a video demonstrating the feature in action. +(Include attachments or links, if applicable.) From 7ba51c84c974c893143053c2d0e1365c5557e0a8 Mon Sep 17 00:00:00 2001 From: Hakaluka Date: Tue, 17 Dec 2024 01:34:40 +0530 Subject: [PATCH 2/6] Update README.md --- README.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index cedc0d5..2f4bfae 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,9 @@ Allows you to organise the passwords better by providing a hierarchical password ##Implementation Details Now you can create folder to divide your passwords into groups like lets say you make a folder named "google" for passwords of g-mail accounts, and "Microsoft" for microsoft accounts. it allows to add passwords in any folder present in the password file. -Demo -Provide screenshots or a video demonstrating the feature in action. -(Include attachments or links, if applicable.) +# Demo + + + +https://github.com/user-attachments/assets/c1f7c094-ed7c-4175-acf6-179aa3269452 + From 4015ec2383818df37fbf5e1d215fc766b52a2dad Mon Sep 17 00:00:00 2001 From: Hakaluka Date: Tue, 17 Dec 2024 01:44:13 +0530 Subject: [PATCH 3/6] Update README.md --- README.md | 144 +++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 133 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 2f4bfae..00acea3 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,140 @@ -#Related Issue -Closes #38 +# Password Manager for MergeFest Event -##Type of Change - New Feature -##Description of Change -Allows you to organise the passwords better by providing a hierarchical password storage in the file. +A **CLI-based password manager** built in Python for secure password storage and management. +--- -##Implementation Details -Now you can create folder to divide your passwords into groups like lets say you make a folder named "google" for passwords of g-mail accounts, and "Microsoft" for microsoft accounts. -it allows to add passwords in any folder present in the password file. -# Demo +## Project Structure +``` +/ +├── main.py # Entry point for executing the program +├── manager.py # Core logic and functionality +``` +--- -https://github.com/user-attachments/assets/c1f7c094-ed7c-4175-acf6-179aa3269452 +## Built With +- **Python**: A versatile programming language. + +--- + +## Resources to Learn Python + +- [Python Tutorial - W3Schools](https://www.w3schools.com/python/) + +--- + +## Contributing + +Before contributing, review the following: + +1. **Rules for MergeFest**: [MergeFest Rules](https://github.com/IMGIITRoorkee/MergeFest-Hacker/blob/main/RULES.md) +2. **Contribution Guidelines**: [How to Contribute](https://github.com/IMGIITRoorkee/MergeFest-Hacker/blob/main/CONTRIBUTORS.md) + +### Contribution Guidelines + +- **Code Style**: Follow best practices for Python coding. +- **Readable Commits**: Write clear and descriptive commit messages. +- **Testing**: Ensure your changes don’t break existing functionality. +- **Proof of Work**: Attach a video showcasing the feature you implemented. + +### Looking for Guidance? + +Join our **Discord server**: [MergeFest Discord](https://discord.gg/aKaEbaVYKf) +Visit the **python** channel and ping `2Y` for assistance. + +--- + +## Setup Instructions + +1. **Fork the Repository** and clone it to your local machine: + ```bash + git clone + cd + ``` + +2. **Set up SSH** for GitHub to commit changes. + +3. **Ensure Python 3 is installed**: + ```bash + python3 --version + ``` + +4. **Install required dependencies**: + ```bash + pip install cryptography + ``` + +5. **Run the Application**: + ```bash + python3 main.py + ``` + +--- + +## Features + +- **Encrypt and Store Passwords**: Securely save your credentials. +- **Key Management**: Generate and load encryption keys. +- **File-Based Storage**: Organize passwords in a file. + +--- + +## Requirements + +- **Python**: Version 3.x or higher. +- **Library**: `cryptography` + +--- + +## How to Use + +1. **Start the Program**: + ```bash + python3 main.py + ``` + +2. **Menu Options**: + - `1`: Create a new encryption key. + - `2`: Load an existing encryption key. + - `3`: Create a new password file. + - `4`: Load an existing password file. + - `5`: Add a new password to the file. + - `6`: Retrieve a password from the file. + - `q`: Quit the application. + +--- + +## Example Usage + +### Create a New Key + +```bash +Enter choice: 1 +Enter key file path: keyfile.key +``` + +### Add a New Password + +```bash +Enter choice: 5 +Enter site: github +Enter password: securepassword123 +``` + +### Retrieve a Password + +```bash +Enter choice: 6 +Enter site: github +Password for github is securepassword123 +``` + +--- + +## Security Note + +- **Keep Your Encryption Key Safe**: + The encryption key is crucial for accessing your passwords. Losing it means your passwords cannot be decrypted. From 273cda5872a12e1a6c5f56af0e7f11e7d0a4287a Mon Sep 17 00:00:00 2001 From: Hakaluka Date: Tue, 17 Dec 2024 01:47:04 +0530 Subject: [PATCH 4/6] Update main.py --- main.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/main.py b/main.py index 57ab52b..2bd6720 100644 --- a/main.py +++ b/main.py @@ -17,6 +17,8 @@ def main(): 4. Load an existing password file 5. Add a password 6. Get a password + 11. Add a folder + 12. Access a folder q. Quit """) @@ -42,6 +44,12 @@ def main(): elif choice == '6': site = input("Enter site: ").strip() print(f"Password for {site}: {pm.get_password(site)}") + elif choice == '11': + name = input("Enter folder name: ").strip() + pm.add_folder(name) + elif choice == '12': + path = input("Enter folder path: ").strip() + pm.access_folder(path) elif choice == 'q': done = True print("Goodbye!") From b60d8636c46817a870615291106556e7029005c9 Mon Sep 17 00:00:00 2001 From: Hakaluka Date: Tue, 17 Dec 2024 01:47:45 +0530 Subject: [PATCH 5/6] Update manager.py --- manager.py | 67 +++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 61 insertions(+), 6 deletions(-) diff --git a/manager.py b/manager.py index 212f675..aaea0c7 100644 --- a/manager.py +++ b/manager.py @@ -6,7 +6,12 @@ class PasswordManager: def __init__(self): self.key = None self.password_file = None + self.numberoffolders=-1 + self.currentfolder=0 + self.folder=[] self.password_dict = {} + self.folder_dict={} + isFolder=False def create_key(self, path): self.key = Fernet.generate_key() @@ -27,15 +32,65 @@ def load_password_file(self, path): self.password_file = path with open(path, 'r') as f: for line in f: - site, encrypted = line.split(":") - self.password_dict[site] = Fernet(self.key).decrypt(encrypted.encode()).decode() - + site, encrypted = line.strip().split(":") + if(site=="folder"): + self.folder.append(encrypted) + self.numberoffolders=self.numberoffolders+1 + self.currentfolder=self.numberoffolders + self.folder_dict[encrypted]=0 + isFolder=True + elif(isFolder): + self.password_dict[site] = Fernet(self.key).decrypt(encrypted.encode()).decode() + self.folder_dict[self.folder[self.numberoffolders]]=self.folder_dict[self.folder[self.numberoffolders]]+1 + else: + self.password_dict[site] = Fernet(self.key).decrypt(encrypted.encode()).decode() + def add_folder(self, name): + self.folder.append(name) + self.numberoffolders=self.numberoffolders+1 + if self.password_file is not None: + with open(self.password_file, 'a+') as f: + encrypted = name + f.write(f"folder:{encrypted}\n") + self.currentfolder=self.numberoffolders + self.folder_dict[name]=0 + def access_folder(self, path): + t=0 + for i in range (len(self.folder)): + if(self.folder[i]==path): + self.currentfolder=i + t=1 + if(t==0): + print("folder not found") + def add_password(self, site, password): self.password_dict[site] = password if self.password_file is not None: - with open(self.password_file, 'a+') as f: - encrypted = Fernet(self.key).encrypt(password.encode()).decode() - f.write(f"{site}:{encrypted}\n") + if (self.currentfolder==self.numberoffolders): + with open(self.password_file, 'a+') as f: + encrypted = Fernet(self.key).encrypt(password.encode()).decode() + f.write(f"{site}:{encrypted}\n") + self.folder_dict[self.folder[self.numberoffolders]]=self.folder_dict[self.folder[self.numberoffolders]]+1 + else: + with open(self.password_file, 'r') as f: + lines=f.readlines() + f.close() + with open(self.password_file, 'w') as f: + count=0 + l=0 + for k in range(self.currentfolder+1): + l+=self.folder_dict[self.folder[k]] + l+=1 + for line in lines: + if(count Date: Tue, 17 Dec 2024 12:47:08 +0530 Subject: [PATCH 6/6] Update README.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 00acea3..53ea2d3 100644 --- a/README.md +++ b/README.md @@ -102,7 +102,9 @@ Visit the **python** channel and ping `2Y` for assistance. - `3`: Create a new password file. - `4`: Load an existing password file. - `5`: Add a new password to the file. - - `6`: Retrieve a password from the file. + - `6`: Retrieve a password from the file. + - `11`: Add a hierarchy heading in password_file + - `12`: Access any hierarchy in the password_file to add password within it - `q`: Quit the application. ---