This project is a CLI password manager that uses Fernet cryptography and MySQL to encrypt and store your passwords.
- MySQL (mysql-connector for python)
- Fernet cryptography (python package)
- Run command:
git clone https://github.com/Cudderson/password-manager.git
- Navigate to the directory for this project and run command:
pip install requirements
import mysql.connector
(-snip-)
# Retrieve password for database connection
with open('password.txt', 'r') as f:
password = f.readline()
def connect_to_database():
db = mysql.connector.connect(
host='localhost',
username='root',
password=password,
database='pm_db',
)
return db
pm_db = connect_to_database()
# Cursor for interacting with database
cursor = pm_db.cursor()
# Retrieve password for database connection
with open('password.txt', 'r') as f:
password = f.readline()
- The connect-to-database()
function will use this password directly in the Python script for connection.
- If you do not wish to store your MySQL password in a text file, you can hard-code it into the connect-to-database()
function, and remove the file-reading code defined above. (Not Recommended)
- Alternatively, you can use any method for password storage that you prefer, so long as the connect-to-database()
function's 'password' argument is properly fulfilled.
Once requirements are installed and you have defined your MySQL database password, this project is ready to run.
- Upon first-launch, the program will connect to your database, store an encryption key, and begin a prompt for a master password creation.
This project uses a main dialogue loop to provide 'modes' for user to access the program's functions and communicate with the database.
Entries in database are stored with an affiliate 'site' name (ex. Youtube), the password itself, and an 'entry_id' that links the Site and Password together through a foreign-key relationship.
(1, 'myspace', 'gAAAAABgNc6jnKws4n3CyQXBr6nEh9dSnaCKbzJUEsCOu28UpxsFt1RWeeOGvCPytPl0Wa5ifrwnLEPXXbivCSjbBowvVp8rSQ==')
(2, 'youtube', 'gAAAAABgNc5EQWI7Jc8WPW-7I3LhJnOBFT3O7kPz7XoDbFQkhUkkQY_qVPiFILz3idXX5nbvPRRmuwlf85ybFKCMFqz1naPclA==')
(3, 'hogwarts', 'gAAAAABgNc64a3cWA6BN2d56X1pNYXv59XGAEgqPgCySahmVDhmTCMZPuOGEugsG4mW58ZIYqgH-OfscKDBSIAgHmMmoT_ev2w==')