mirror of
https://github.com/metafy-social/python-scripts.git
synced 2025-01-18 07:17:03 +00:00
Added Password Manager
This commit is contained in:
parent
3a1ddfad4a
commit
e8fe10fdc1
50
scripts/Password Manager/password_manager.py
Normal file
50
scripts/Password Manager/password_manager.py
Normal file
|
@ -0,0 +1,50 @@
|
|||
from cryptography.fernet import Fernet
|
||||
|
||||
'''
|
||||
def write_key():
|
||||
key = Fernet.generate_key()
|
||||
with open("key.key", "wb") as key_file:
|
||||
key_file.write(key)'''
|
||||
|
||||
|
||||
def load_key():
|
||||
file = open("key.key", "rb")
|
||||
key = file.read()
|
||||
file.close()
|
||||
return key
|
||||
|
||||
|
||||
key = load_key()
|
||||
fer = Fernet(key)
|
||||
|
||||
|
||||
def view():
|
||||
with open('passwords.txt', 'r') as f:
|
||||
for line in f.readlines():
|
||||
data = line.rstrip()
|
||||
user, passw = data.split("|")
|
||||
print("User:", user, "| Password:",
|
||||
fer.decrypt(passw.encode()).decode())
|
||||
|
||||
|
||||
def add():
|
||||
name = input('Account Name: ')
|
||||
pwd = input("Password: ")
|
||||
|
||||
with open('passwords.txt', 'a') as f:
|
||||
f.write(name + "|" + fer.encrypt(pwd.encode()).decode() + "\n")
|
||||
|
||||
|
||||
while True:
|
||||
mode = input(
|
||||
"Would you like to add a new password or view existing ones (view, add), press q to quit? ").lower()
|
||||
if mode == "q":
|
||||
break
|
||||
|
||||
if mode == "view":
|
||||
view()
|
||||
elif mode == "add":
|
||||
add()
|
||||
else:
|
||||
print("Invalid mode.")
|
||||
continue
|
2
scripts/Password Manager/passwords.txt
Normal file
2
scripts/Password Manager/passwords.txt
Normal file
|
@ -0,0 +1,2 @@
|
|||
joe|gAAAAABgjFWyJO-TuQzczus2VTKZEkiQm40dWlU49uG4s0KztOLsTMCXUDN7DSSytU7w9ArgVZzhvt3oivFfFty1DwO0yZ71Fw==
|
||||
billy|gAAAAABgjFYUZ22T15aXZyx72CpbC0Rd6hRcxq82RiAMn5Pj2WoMyzy8zAInqvwhg04LNWsW7lnlx3_RHpEEQ9fzhIYG9F0-lA==
|
Loading…
Reference in New Issue
Block a user