Share your repls and programming experiences

← Back to all posts
Login program
TripleJ123

A little login program I created. Please suggest more ideas or faults in the comments.
Thanks

Voters
VARSHAM2
aaronowen2004
Seraphis333
RichardKukura1
rajendraraghuva
PRAVINCHOUDHARY
techgeek680
sandrew588
TripleJ123
Comments
hotnewtop
DrAvery

I made my own "Login/Register" Python program a while back. You can find that here: https://repl.it/@DrAvery/LoginRegister

Although the code is written for Tkinter, the same idea would apply to a console or IDE driven version of this; load a json file (create one if it doesn't exist, dumping an empty json dictionary to it so you are able to read and write json data without any errors and whatnot) so you are able to check whether a given username exists, and, if it does, that the given password for that username is the one that is stored.

Also, I used SHA3_256 to encrypt the password, making it so that the password is not stored in plain text in a text file. By encrypting the password with a function when a user first registers, you can then make a dictionary with the username as the key and the encrypted password as the value of that key. An example of such for a console or IDE driven version would be as follows:

Username: DrAvery
Password: Password

The haslibs module for Python would then take the password "Password" and encrypt it with SHA3_256, which is "e7cf3ef4f17c3999a94f2c6f612e8a888e5b1026878e4e19398b23bd38ec221a." We can then create the Python dictionary:

usernames_and_passwords = {
"DrAvery": "e7cf3ef4f17c3999a94f2c6f612e8a888e5b1026878e4e19398b23bd38ec221a"
}

Using this Python dictionary, we can then use a json.dump() and dump the json output to a file.

When you want to check if a given username and the associated password exist, you would write something simmilar to the following:

for i in usernames_and_passwords:
... code stuff here ...

I hope this helped,
Dr. Avery

ElysaBakaa

.

UwaiseNoorani1

what do you do?

HappyFakeboulde

and have some system of saving logins in an external file

HappyFakeboulde

You should encrypt the passwords

WonderNote18

You should add try/except checks so that if someone entered blank input (just spamming enter) it would go through the checks in the loops instead of bypassing your loop's arguments. Through this error, I was able to login with a blank username/password.

try:
inputusername = input("What is the username?")
except SyntaxError:
inputusername = None

If the input above returns a SyntaxError, it'll return the variable with a value of None instead of no value at all. Otherwise, it will return the variable with whatever value was inputted.