Back when I wrote Perfect Passwords, I generated a list of the top 500 worst (aka most common) passwords which seems to have propagated quite a bit across the internet, including being mentioned on Gizomodo, Boing Boing, Symantec, Laughing Squid and many other sites. Since then I have collected a large number of new passwords bringing my current list to about 6.5 million unique username.
I'm writing a program which will need a user to register and login with an account. I get the program to have the user make their username and password which are saved in an external text file (accountfile.txt), but when it comes to the login I have no idea how to get the program to check if what the user inputs is present in the text file.
This is what my bit of code looks like :
I have no idea what to do from this point.
Also, this is what a registered account would look like in the text file:
OSGOSG
1 Answer
After opening the file, you can use
readlines()
to read the text into a list of username/password pairs. Since you separated username and password with a space, each pair is string that looks like 'Na19XX myPassword'
, which you can split into a list of two strings with split()
. From there, check whether the username and password match the user input. If you want multiple users as your TXT file grows, you need to add a newline after each username/password pair.
Brenden PetersenBrenden Petersen
![Txt Txt](/uploads/1/2/4/8/124888000/314893200.png)
![Password Password](/uploads/1/2/4/8/124888000/658491839.jpg)
protected by Community♦Nov 8 '18 at 10:33
Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?
Would you like to answer one of these unanswered questions instead?