Python Forum
[URGENT] Trying to create a simple password manager in python
Thread Rating:
  • 1 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[URGENT] Trying to create a simple password manager in python
#1
Hi, all apologies if this is in the wrong spot or my program has some basic errors as I am relatively new to both python  and this forum. I continuesly run into problems with this code, I am trying to have a master key registration and a login menu which checks the contents of a text file containing the master key before been able to add records such as usernames and other data. Any help would be mostly appreciated. thanks

code:

#importing all necessary modules

import pickle
import random
import os
import tkinter

MasterKeyList = []
UserRecordsList = []

#Specifying paths for source files

fileIn1 = "MasterRecords.txt"
fileOut1 = "MasterRecords.txt"

fileIn2 = "UserRecords.txt"
fileOut2 = "UserRecords.txt"

######################################################################################################################################

# defining all necessary variables

def AddAccount(UserRecords):
    with open(fileOut2, "wb") as file:
        pickle.dump((UserRecords), (file))

def EditAccount(UserRecords):
    for i in range(len(UserRecords)):
        if records[i][0] == AccountName:
            records[i] = newRecord
        break
    return records

def FindAccount(UserRecords):
    AccountName = input("Enter the name of the account you wish to search for e.g reddit")

    for i in range(len(records)):
        if UserRecords[i][1].lower() == AccountName:
            return UserRecords[i]

def DeleteAccount(UserRecords):
        for i in range(len(UserRecords)):
            if UserRecords[i][0] == AccountName:
                del UserRecords[i]
                break
            
        return UserRecords 

def CreateMasterKey(NewKey):
        with open(fileOut1, "wb") as file:
            pickle.dump((NewKey), (file))

def GetMasterKey(MasterRecords):
    MasterKey
######################################################################################################################################

# First menu 

# Login stage
def login():
    attempts = 3

    choosing = True
    while choosing:
        choice = int(input("1)Login\n2)Register\n3)Quit\n> "))

        # login
        if choice ==1:
            for cd in reversed(range(attempts)):
                MasterKey = input("Enter your master key to continue:")
                if input("Enter your master key to continue:") == MasterKey():
                    return True
                else:
                    print ("Incorrect, {} attempts remaining..".format(cd))
            return False

        # Registration stage
        elif choice ==2:
            if choice ==2:
                print ("Welcome to SmartPass please create your master key,")
                print ("this key will be required the next time you login")
                print ("please take not of this key as you will be unable to recover it if lost.")
                print ("")
                print ("")
            MasterKey = input("Enter your master Key:")
            print("Your master key has been successfully created!")
            CreateMasterKey(NewKey)
            LoggedIn = True
            choosing = False

        # Quit option
        elif choice ==3:
            print("Thank you for using SmartPass, bye now")
            os.exit(3)

        else:
            print("Invalid input, please try again")

def main():

    if login():
        print("You are currently logged in to SmartPass")
        loggedIn = True

        while LoggedIn:
            choice = int(input("1)Add account\n2)Edit\n3)Display all accounts\n4)Find account\n5)Delete account\n6)Generate random password\n7)Logout\n> "))
                        
        # Add Account option
        if choice ==1:
            account = "stuff"
            AddAccount(UserRecords)

        # Edit Account option
        elif choice ==2:
            input("Enter the name of the account you wish to edit:")
            EditAccount(UserRecords)

        # View all accounts/records
        elif choice ==3:
            DisplayAccounts(UserRecords)

        # Find Account
        elif choice ==4:
            print("Enter the name of the account you would like to find e.g facebook")
            FindAccount(UserRecords)

        # Delete Account
        elif choice ==5:
            DeleteAccount(UserRecords)

        # Generate random password option
        elif choice ==6:
            alphabet = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ#!$&(@3187%=+}{<->?"
        pw_length = 15
        mypw = ""

        for i in range(pw_length):
            next_index = random.randrange(len(alphabet))
        mypw = mypw + alphabet[next_index]

        print(mypw)

        # Logout and quit program
        if choice ==7:
            LoggedIn = False
            print("Logging out of your session....")

        else:
            print("You are now logged out, bye!")

if __name__ == "__main__":
    main()
Reply


Messages In This Thread
[URGENT] Trying to create a simple password manager in python - by equanox314 - Jul-27-2017, 12:32 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Exclamation Python Homework (Urgent help needed!!) chickenseizuresalad 6 4,381 Oct-11-2021, 01:59 AM
Last Post: Underscore
Exclamation urgent , Python homework alm 2 2,350 May-09-2021, 11:19 AM
Last Post: Yoriz
  urgent I got a syntax errors alm 2 5,933 Feb-28-2021, 02:54 PM
Last Post: alm
Heart Urgent homework help needed Medou 4 2,783 Nov-24-2020, 09:28 AM
Last Post: buran
  Python project help (Password manger using mysql) lifeofpy 2 4,744 Jul-31-2020, 06:18 PM
Last Post: deanhystad
  Python Password Saver Assignment sshellzr21 2 6,236 May-02-2020, 01:34 AM
Last Post: sshellzr21
  How to create simple thread safe singletone that protect __init__ on import module umen 0 1,679 Apr-16-2020, 09:43 AM
Last Post: umen
  [Urgent] build code GodMaster 2 1,835 Mar-23-2020, 12:25 AM
Last Post: jefsummers
  Bifid Genkey (Urgent) Laura123 2 2,082 Mar-09-2020, 08:09 PM
Last Post: micseydel
  Python Homework Help *Urgent GS31 2 2,626 Nov-24-2019, 01:41 PM
Last Post: ichabod801

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020