0% found this document useful (0 votes)
50 views3 pages

Password Manager Script Guide

This document outlines a simple password manager program that allows users to list, add, and view accounts stored in a JSON file. It includes functions for managing passwords, such as saving and loading from a file, and provides a menu-driven interface for user interaction. The program handles user input and displays relevant messages based on the actions performed.

Uploaded by

Rashin Richu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views3 pages

Password Manager Script Guide

This document outlines a simple password manager program that allows users to list, add, and view accounts stored in a JSON file. It includes functions for managing passwords, such as saving and loading from a file, and provides a menu-driven interface for user interaction. The program handles user input and displays relevant messages based on the actions performed.

Uploaded by

Rashin Richu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

def list_accounts():

for account in passwords:

print(account)

def add_account():

website = input("Website: ")

username = input("Username: ")

password = input("Password: ")

passwords[website] = {"username": username, "password": password}

save_passwords()

print(f"Password for {website} added successfully!")

import json

# Initialize an empty dictionary to store passwords

passwords = {}

def save_passwords():

with open("passwords.json", "w") as file:

json.dump(passwords, file)

def load_passwords():

try:

with open("passwords.json", "r") as file:

return json.load(file)

except FileNotFoundError:

return {}
def view_account():

website = input("Website: ")

account = passwords.get(website)

if account:

print(f"Username: {account['username']}")

print(f"Password: {account['password']}")

else:

print(f"No account found for {website}")

def main():

global passwords

passwords = load_passwords()

while True:

print("\nPassword Manager Menu:")

print("1. List Accounts")

print("2. Add Account")

print("3. View Account")

print("4. Exit")

choice = input("Enter your choice: ")

if choice == "1":

list_accounts()

elif choice == "2":

add_account()

elif choice == "3":

view_account()

elif choice == "4":


print("Exiting Password Manager.")

break

else:

print("Invalid choice. Please try again.")

if __name__ == "__main__":

main()

You might also like