From a7cd5563ce6b8b014733202edae07c85358ce09a Mon Sep 17 00:00:00 2001 From: vijay Date: Wed, 8 Jul 2020 15:56:07 +0530 Subject: [PATCH] Encrypted the password entered --- Password Manager/src/Modules/Functions.py | 29 +---------------- Password Manager/src/Modules/Password.py | 38 +++++++++++++++++++++++ Password Manager/src/Password_manager.py | 1 + 3 files changed, 40 insertions(+), 28 deletions(-) create mode 100644 Password Manager/src/Modules/Password.py diff --git a/Password Manager/src/Modules/Functions.py b/Password Manager/src/Modules/Functions.py index 779b3ab..e039a19 100644 --- a/Password Manager/src/Modules/Functions.py +++ b/Password Manager/src/Modules/Functions.py @@ -50,31 +50,4 @@ def check_details(account): def destroy(): cursor.execute('DELETE from DETAILS;',) print("\nDelete",cursor.rowcount,"records\n") - conn.commit() - -def password_function(): - try: - file = open('../temp/password.txt', 'r') - password = file.read() - while(True): - entered_password = input("Enter your password \n> ") - if(password == entered_password): - green("Logged in successfully") - grey("Press any key to continue...") - input() - break - else: - red("Incorrect password") - except: - green("PASSWORD MANAGER") - cyan("-" * 25) - print("Since, this is the first time you are using Password_manager, Create a password.") - red("DO NOT FORGET THIS PASSWORD. YOU CANNOT CHANGE IT LATER.") - password = input("Enter your password \n> ") - file = open('../temp/password.txt', 'w') - file.write(password) - green("Your password has been saved successfully") - cyan("Relaunch the application to continue.") - grey("Press enter to exit...") - input() - sys.exit(0) \ No newline at end of file + conn.commit() \ No newline at end of file diff --git a/Password Manager/src/Modules/Password.py b/Password Manager/src/Modules/Password.py new file mode 100644 index 0000000..404055e --- /dev/null +++ b/Password Manager/src/Modules/Password.py @@ -0,0 +1,38 @@ +from Modules.Colours import * +from cryptography.fernet import Fernet + +def password_function(): + + file = open('../temp/key.txt','rb') + key = file.read() + file.close() + + try: + file = open('../temp/password.txt', 'r') + password = file.read() + while(True): + entered_password = input("Enter your password \n> ") + if(password == entered_password): + green("Logged in successfully") + grey("Press any key to continue...") + input() + break + else: + red("Incorrect password") + except: + green("PASSWORD MANAGER") + cyan("-" * 25) + print("Since, this is the first time you are using Password_manager, Create a password.") + red("DO NOT FORGET THIS PASSWORD. YOU CANNOT CHANGE IT LATER.") + + password = input("Enter your password \n> ") + fernet = Fernet(key) + encrypted = fernet.encrypt(password) + + file = open('../temp/password.txt', 'w') + file.write(encrypted) + green("Your password has been saved successfully") + cyan("Relaunch the application to continue.") + grey("Press enter to exit...") + input() + sys.exit(0) \ No newline at end of file diff --git a/Password Manager/src/Password_manager.py b/Password Manager/src/Password_manager.py index d1e4adc..63288a9 100644 --- a/Password Manager/src/Password_manager.py +++ b/Password Manager/src/Password_manager.py @@ -4,6 +4,7 @@ import sys from Modules.Functions import * from Modules.Colours import * +from Modules.Password import * if __name__ == "__main__": os.system('cls')