Assignment 6
Passwords: Loops and Fruitful Functions
Submit before 11:30 PM Saturday May 18
Overview
For this assignment, you are given a file with encrypted passwords. Your assignment is to write Python scripts that try to "guess" as many passwords as possible.
Python Functions
- Guessing one password: write a function called guess that takes a string (a guessed password) as an argument and prints out matching information if its encrypted string matches any of the strings in the encrypted password file (zip folder with encrypted.txt file --- Version 2). When you write the function, you may hardcode the name of the password file.
Here is an example run:
>>> guess("blue") Found match: blue Line number: 1 Encrypted value: 16477688c0e00699c6cfa4497a3612d7e83c532062b64b250fed8908128ed548
You will want to use the encrypt function presented in class .
- Modify your guess so that it returns a 1 if there's a match, 0 otherwise. You may choose to keep the print statements.
- Guessing many passwords: Write a function
called guess_passwords. It doesn't take any
arguments. It should use the function guess, trying out as many
possible passwords as possible. Here are some methods you might try:
- Try out a hardcoded list of strings that you think people might use as passwords.
- Try out all words in the word file.
- Try out all character combinations of length 4 or less (or more if you don't mind waiting).
- Try out combinations of words and numbers.
- Try out capitalized versions of any of the above
For full credit, you must try out at least three approaches, such as those listed above or of your own devising.
The function guess_passwords should report (print) the total number of guessed passwords, totalling the number of 1s returned by guess.
Deliverables
Create a summary file called assn6 (pdf or txt) that contains the following:
- A statement that summarizes your completion of the assignment. Discuss your experience. This statement should include the number of paswords you were able to guess and the approaches you used. Note any help or collaboration.
- For each of your Python code problems:
- A listing of the code (copy the code in the py file and past it in the assn1 file)
- Running examples that demonstrate that your code works correctly (copy the text that shows your py file running and paste it in the assn6 file)
Submit your assn6.pdf (or assn6.txt) file to D2L.