Skip to content

Instantly share code, notes, and snippets.

@mchow01
Last active March 3, 2021 04:35
Show Gist options
  • Save mchow01/049608736c7ae492219ee74580465fc1 to your computer and use it in GitHub Desktop.
Save mchow01/049608736c7ae492219ee74580465fc1 to your computer and use it in GitHub Desktop.
A tally program for password cracking competition
import glob, os
passwords =[]
results = {}
student_totals = {}
password_totals = {}
for filename in os.listdir("."):
if filename.endswith(".html"):
results[filename] = {}
for password in passwords:
results[filename][password] = 0
student_totals[filename] = 0
for password in passwords:
password_totals[password] = 0
submission = open(filename, "r")
for line in submission:
for password in passwords:
if line.find(password) != -1:
results[filename][password] = 1
submission.close();
for student in results:
for password in passwords:
student_totals[student] += results[student][password]
password_totals[password] += results[student][password]
for student in student_totals:
print(student + "\t" + str(student_totals[student]))
print("\n")
for password in password_totals:
print(password + "\t" + str(password_totals[password]))
@mchow01
Copy link
Author

mchow01 commented Mar 3, 2021

Updated for submissions made to Canvas

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment