In [1]:
# read passwords into list
#todo:
#input: none, output: list of bad passwords
# for each line in bad-passwords.txt
# add to list
def read_passwords():
bad_password_list = []
filename = "ETEE-bad-passwords.txt"
with open(filename) as f:
for line in f:
bad_password_list.append(line.strip())
return bad_password_list
# password in list?
#input: password list and a password to check, output: True or False
#todo
# get index of password in list
# return true
# when ValueError return false
def password_in_list(password, bad_password_list):
try:
index = bad_password_list.index(password)
return True
except ValueError:
return False
# main program
bad_password_list = read_passwords()
print("This program will check for quality passwords against a list of known bad passwords.")
while True:
password = input("Enter a password or ENTER to quit: ")
if password == "":
break
if password_in_list(password, bad_password_list):
print("%s is a bad password. It is on the list." % (password))
else:
print("%s seems like an ok password. It is not on the list." % (password))
In [ ]: