awesomesciencegirl-
I'm sorry that no one answered your question. The experts here generally try to make sure everyone gets an answer. I'm not sure what happened. I hope the fair went well for you and that you figured this out for yourself. Again, I'm sorry we didn't help.
You were on the right track though. The guessing methods generate the guess and pass that along with a number from 0 to 6 to the checking function. All you needed to do is set up your 'guessmypassword()' like you had planned and tell it which of the passwords it's guessing. I took the main() function from the downloaded version, broke it into two and did this which I think is what you were looking for:
Code: Select all
def main(argv=None):
global password0, password1, password2, password3
global password4, password5, password6, totalguesses
global which_password
# This is a place for you to set a password of your own
password0 = "314"
# Set up the passwords we want to crack. These must be MD5 hash
# data blocks. Set them up using MD5me like:
# 'password1=MD5me("ScienceBuddies")'
#
password1="202cb962ac59075b964b07152d234b70"
password2="570a90bfbf8c7eab5dc5d4e26832d5b1"
password3="f78f2477e949bee2d12a2c540fb6084f"
password4="09408af74a7178e95b8ddd4e92ea4b0e"
password5="2034f6e32958647fdff75d265b455ebf"
password6="9b3af42d61cde121f40b96097fb77d3e"
for num in range(0,5):
print("")
print("* * * * * * *")
guessmypassword(num)
def guessmypassword(n):
# start searching
which_password = n
## which_password = int(input("Which password (0-6)? "))
overallstart = time.time()
foundit = False
print("Trying to guess password "+str(which_password))
# Look through our list of common passwords first
if not foundit:
foundit = search_method_3("passwords.txt")
# Still looking? Let's combine the common passwords 2 at a time
if not foundit:
foundit = search_method_4("passwords.txt")
# Still looking? See if it's a single digit
if not foundit:
foundit = search_method_1(1)
# Still looking? See if it's a 2 digit number
if not foundit:
foundit = search_method_1(2)
# Still looking? See if it's a 3 digit number
if not foundit:
foundit = search_method_1(3)
# Still looking? See if it's a 4 digit number
if not foundit:
foundit = search_method_1(4)
# Still looking? Use our rotary wheel simulation up to 6 wheels.
# This should take care of any 5 digit number as well as letter
# combinations up to 6 characters
if not foundit:
foundit = search_method_2(6)
# Still looking? Try 7 digit numbers
if not foundit:
foundit = search_method_1(7)
# Still looking? Try 8 digit numbers
if not foundit:
foundit = search_method_1(8)
seconds = time.time()-overallstart
# When testing this project, some users reported that the next lines of code reported
# an error when Python tried to divide by zero. On those machines, the clock seems
# to think that the seconds calculation just above gave us "zero" seconds which doesn't
# make any sense. To avoid the crash though, we'll test for that case and avoid the
# problem.
if (seconds < 0.00001):
print ("The total search for all methods took "+make_human_readable(seconds)+" seconds and "+make_human_readable(totalguesses)+" guesses.")
print ("(on some machines, Python doesn't know how long things actually took)")
else:
print ("The total search for all methods took "+make_human_readable(seconds)+" seconds and "+make_human_readable(totalguesses)+" guesses.("+make_human_readable(totalguesses/seconds)+" guesses per second)")
if foundit:
if (6 == which_password):
print("Wow! Be sure to confirm your find at https://www.sciencebuddies.org/science-fair-projects/project_ideas/CompSci_p046/PasswordCrack.shtml")
elif (0 == which_password): # The Science Buddies website can't confirm passwords you added yourself
print ("Your algorithm correctly guessed the password you entered. Try some others or see if you can make it guess faster.")
else:
print("You can confirm your find at https://www.sciencebuddies.org/science-fair-projects/project_ideas/CompSci_p046/PasswordCrack.shtml")
The guessing is exactly the same, but instead of asking you which one to guess, it iterates from 0 to 5 as you had planned. I hope seeing the technique is still helpful.
Howard