User Selected Settings/configuration

I am working on my first ever python project. The premise is a program that mainly is meant to hide login information for different applications, websites, services, etc. And right now the way you do that is to write that information in the code and make an executable. But I want it so that its one application and when it is first launched the user is prompted to se their own passcode to access the hidden information as well a way to enter new information to hide.

This is my current code.
For reference I use PyCharm


# Enter your the masterpassword of your choosing here.
passcode = "1123"

# This asks you to enter your passcode to access your information
while (True):
    ask_passcode = input("Enter Passcode: ")
    if ask_passcode == passcode:
        print("Passcode Correct")
        # This next segment will display all your login information and domain.
        # How you format how the information looks on the actual executable is up to you.
        # What's written is just an example.
        # To add new entries write print("") Write whatever information you want between the quotation marks.
        print("Domain: abc.com | Username: abcdefg | Password: 12345678")
    # if the passcode is incorrect it will run this line of code before restarting the loop.
    else:
        print("Try Again")

The help I need is finding out where to start. If I can figure that out then It wont be terribly hard to figure out how to do this.Preformatted text

Hello, @Cloverexe, and welcome to the Python Community!

Is this homework?

Note this line:

while (True):

That line is currently the header of an infinite loop. To enable the loop to terminate, you can add a break statement at the end of the if block. That should occur right after this line:

        print("Domain: abc.com | Username: abcdefg | Password: 12345678")

Make sure that the break statement is indented to the exact same degree as that print statement.

Try adding that break statement, then run the program. When it runs, first enter an invalid passcode, when prompted. Next time, enter the valid one. The program should respond to the latter by revealing one line of information.

After you have it working, copy and paste the print statement several times. Paste the copies on successive lines right after the existing print statement. Then modify the copies to present login information for other applications, websites, and services. Test and refine it again until you are satisfied with it.

This is not homework.
I know that the while (True): statement is an infinite loop. Im going to remove the print line eventually but I have it as an infinite loop so it will keep prompting you for a password until you enter the correct one. And a break statement if the condition is true is a good suggestion for stopping the loop. So thanks for that suggestion!

1 Like

What you have there is fine. It is a good beginning for what you are doing. With the necessary break statement added, the loop will keep prompting you for a password until you enter the correct one. Then, with the correct one entered, the program will display the login information for any applications, websites, and services that you include in your code, and then terminate.

You do not need to remove the existing print statement. All you need to do with the existing code is to add a new print statement for each additional application, website, or service, and add the break after the last one. If you want, you can also modify the existing print statement.

Just to note, while this is fine for learning Python DO NOT actually use this for anything, as it is trivially easy for anyone to simply find your (hardcoded) password in the Python source code, or wherever you store it. A better way would be encrypting the protected information (i.e. with a third party Python library, like cryptography) with the passcode as the key and storing the encrypted data somewhere. Even better would be using the keyring Python library to use your OS’s built-in facilities for storing secrets from Python, avoiding the extra work and mistakes of building your own. But still better, if you’re actually going to use this, use an existing open source password manager like Bitwardin, or one built into the OS, as it is very very easy to make mistakes and leave yourself vulnerable.