Skip to content

Commit

Permalink
Merge pull request #7 from Mmabiaa/Other
Browse files Browse the repository at this point in the history
Other
  • Loading branch information
Mmabiaa authored Jan 4, 2025
2 parents 5c1ece6 + 17fffd6 commit 1aeb672
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 15 deletions.
9 changes: 6 additions & 3 deletions Codes/app.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
# app.py


from green import print_green
import getpass
# import other module associated to this file.=======
# Author - Mmabiaa

import getpass

from password_manager import *

# Function to print in green
def print_green(text):
print("\033[32m" + text + "\033[0m")



Expand Down
3 changes: 3 additions & 0 deletions Codes/green.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Function to print in green
def print_green(text):
print("\033[32m" + text + "\033[0m")
25 changes: 13 additions & 12 deletions Codes/password_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
import base64
import os
import secrets
import string
import string
from green import print_green


def hash_password(password):
Expand All @@ -27,7 +28,7 @@ def register():

with open('user_data.json', 'w') as file:
json.dump({'username': username, 'master_password': master_password_hash}, file)
print('\n[+] Registration Completed!!\n')
print_green('\n[+] Registration Completed!!\n')


def login(username, entered_password):
Expand All @@ -41,16 +42,16 @@ def login(username, entered_password):
entered_password_hash = hash_password(entered_password)

if entered_password_hash == stored_password and username == user_data.get('username'):
print('\n[+] Login Successful...\n')
print_green('\n[+] Login Successful...\n')
return True

else:
print('\n[+] Invalid Login Credentials... Login Failed!!\n')
print('\n[+] Use the registered credentials to login')
print_green('\n[+] Invalid Login Credentials... Login Failed!!\n')
print_green('\n[+] Use the registered credentials to login')
sys.exit()

except Exception:
print('\n[+] You must register to begin...!!!\n')
print_green('\n[+] You must register to begin...!!!\n')
sys.exit()

def generate_key(master_password):
Expand Down Expand Up @@ -98,20 +99,20 @@ def save_password(website, username, password, key):

with open('password.json', 'w') as file:
json.dump(passwords, file)
print(f'\n[+] Password saved for {website}...\n')
print_green(f'\n[+] Password saved for {website}...\n')

def view_saved_websites(key):
"""View saved websites and their passwords."""
try:
with open('password.json', 'r') as file:
passwords = json.load(file)
print("Websites you saved...")
print_green("Websites you saved...")
for website, data in passwords.items():
encrypted_password = data['password'].encode()
decrypted_password = decrypt_password(encrypted_password, key)
print(f"Website: {website}")
print(f"Username: {data['username']}")
print(f"Password: {decrypted_password}\n")
print_green(f"Website: {website}")
print_green(f"Username: {data['username']}")
print_green(f"Password: {decrypted_password}\n")
except FileNotFoundError:
print('\n[+] No passwords saved yet...\n')
print_green('\n[+] No passwords saved yet...\n')

0 comments on commit 1aeb672

Please sign in to comment.