Password Manager with Cryptography Integration

Password Manager with Cryptography Integration

Password Manager with Cryptography Integration

Password Manager with Cryptography Integration

This project implements a Password Manager that uses the Fernet class from the cryptography module to encrypt and decrypt user passwords. The application allows users to securely store their account passwords and retrieve them when needed, ensuring a safe and user-friendly experience.

My Approach

The Password Manager is designed with security and simplicity in mind. By utilizing the Fernet encryption from the cryptography library, the project ensures that passwords are stored in an encrypted format, making them unreadable without the correct decryption key. The application provides two main functionalities: adding new passwords and viewing stored ones.

Key Features

  1. Encryption with Fernet: The application generates a secure encryption key using Fernet.generate_key(), which is then stored in a local file called key.key. This key is used to both encrypt and decrypt the passwords, ensuring their security.

  2. Password Storage: Usernames and encrypted passwords are stored in a plain text file called password.text, with each entry formatted as Account | Encrypted Password.

  3. Decryption and Viewing: When viewing stored passwords, the Fernet key is used to decrypt the password, making it readable for the user.

  4. User Input: The program allows users to interactively choose whether to add a new password or view the existing ones.

GITHUB LINK:: https://github.com/ibtihajjutt/Password-Manager-Python

CODE

from cryptography.fernet import Fernet


def write_key():
    key = Fernet.generate_key()
    with open('key.key', 'wb') as k:
        k.write(key)

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('password.text', 'r') as f:
        for line in f:
            data = line.rstrip()
            user, passw = data.split("|")
            print("User:", user.strip(), "| Password:", fer.decrypt(passw.strip().encode()).decode())

def add():
    name = input("Enter Account name: ")
    pwd = input("Enter Password: ")
    encrypted_pwd = fer.encrypt(pwd.encode())
    with open('password.text', 'a') as f:
        f.write(name + " | " + encrypted_pwd.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
    elif mode == "view":
        view()
    elif mode == "add":
        add()
    else:
        print("Invalid mode")

Other Projects

Let's Connect!

Let's Connect!

Let's Connect!

© Copyright 2024. All rights Reserved.

Created by

Ibtihaj

in

© Copyright 2024. All rights Reserved.

Created by

Ibtihaj

in