Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for environment variable key loading#35 #108

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
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
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
KEY=<insert your key here>
8 changes: 7 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from manager import PasswordManager
import pyperclip
import os
from dotenv import load_dotenv


load_dotenv('.env')


def validate_key_loaded(pm : PasswordManager):
Expand All @@ -22,6 +24,7 @@ def main():
print("""What would you like to do?
1. Create a new key
2. Load an existing key
21. Load from the enviroment variable
3. Create a new password file
4. Load an existing password file
5. Add a password
Expand All @@ -39,6 +42,9 @@ def main():
elif choice == '2':
path = input("Enter key file path: ").strip()
pm.load_key(path)
elif choice == '21':
key=os.getenv('KEY')
pm.load_key_from_env(key)
elif choice == '3' and validate_key_loaded(pm):
path = input("Enter password file path: ").strip()
pm.create_password_file(path, password)
Expand Down
3 changes: 3 additions & 0 deletions manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ def load_key(self, path):
with open(path, 'rb') as f:
self.key = f.read()
self.keyloaded = True
def load_key_from_env(self,key):
self.key = key
self.keyloaded = True


def create_password_file(self, path, initial_values=None):
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
pyperclip
pyperclip
python-dotenv