URGENT! Python problems.

Ask questions about projects relating to: computer science or pure mathematics (such as probability, statistics, geometry, etc...).

Moderators: AmyCowen, kgudger, bfinio, MadelineB, Moderators

Locked
cargupta
Posts: 6
Joined: Sun Jan 24, 2016 10:45 am
Occupation: Student

URGENT! Python problems.

Post by cargupta »

Hello, my name is cargupta. I am in the 6th grade.
I've been coding Java, C++, HTML, CSS, and JavaScript for two years. I wanted to start something new so, I decided to code with Python and do a project from ScienceBuddies (https://www.sciencebuddies.org/science- ... p046.shtml.) I've run the program with the 5 passwords Science Buddies provides. However, when I try to put in my own password to decrypt(Password 0) my program just crashes.

NOTE: I do have the passwords.txt file.

Thanks :D,
- CarGupta

PC SPECS

Python 2.7


7.8 GB RAM

Intel® Core™ i7-3770S CPU @ 3.10GHz × 8 Processor

Gallium 0.4 on AMD TURKS (DRM 2.43.0, LLVM 3.6.2) Video Card

483.8 GB HD

Ubuntu Linux(Debian) 15.10


CODE

Code: Select all

#!/usr/bin/python

# This program is offered for use with the Science Buddies project idea
# "How Easily Can Your Password Be Hacked?" which lets you explore the
# makeup of a good password. This program will help you understand some
# methods that people use to guess other people's passwords.
#
# the program begins execution at 'main' after the helper programs and functions
# are defined. You'll also notice that several functions have places where 
# print() functions have been turned into comments. When debugging a program, it's
# helpful to add in more descriptive screen output than you might want later on.
# Once the program is working, you can remove the extra output os, as we've done here,
# 'comment it out' so that someone else can use it again later on if they decide to 
# modify your program.

#Tell Python we want to use some functions it doesn't always use
import sys, time, hashlib
from array import *

#--------------- global variables we expect will be used by any function -----------
#
# a number from 1 to 6 selects which password we'll be trying to guess from
# a selection below.
which_password = 0

# the user names and password we're trying to 'crack'. These will get written
password0 = ""
password1 = ""
password2 = ""
password3 = ""
password4 = ""
password5 = ""
password6 = ""


# total number of guesses we had to make to find it
totalguesses = 0


#--------------- extra helper functions -------------------
# These will be used by our search routines later on. We'll get these defined and out
# of the way. The actual search program is called "main" and will be the last one
# defined. Once it's defined, the last statement in the file runs it.
#
#


## Convert a string into MD5 hash
def MD5me(s):
    result = s.encode("utf-8")
    result = hashlib.md5(result).hexdigest()
    return result

# Takes a number from 0 on up and the number of digits we want it to have. It uses that
# number of digits to make a string like "0000" if we wanted 4 or "00000" if we wanted
# 5, converts our input number to a character string, sticks them together and then returns
# the number we started with, with extra zeroes stuck on the beginning. 
def leading_zeroes(n, zeroes):
    t=("0"*zeroes)+str(n)
    t=t[-zeroes:]
    return t

# check_userpass
def check_userpass(which_password, password):
    global password0, password1, password2, password3
    global password4, password5, password6
    
    result = False

    if (0 == which_password):
        if password == password0:
            result = True

    if (1 == which_password):
        if MD5me(password) == password1:
            result = True

    if (2 == which_password):
        if (MD5me(password) == password2):
            result = True

    if (3 == which_password):
        if (MD5me(password) == password3):
            result = True

    if (4 == which_password):
        if (MD5me(password) == password4):
            result = True
            
    if (5 == which_password):
        if (MD5me(password) == password5):
            result = True
            
    if (6 == which_password):
        if (MD5me(password) == password6):
            result = True
            
    return result

# This displays the results of a search including tests per second when possible
def report_search_time(tests, seconds):
    if (seconds > 0.000001):
        print ("The search took "+make_human_readable(seconds)+" seconds for "+make_human_readable(tests)+" tests or "+make_human_readable(tests/seconds)+" tests per second.")
    else:
        print ("The search took "+make_human_readable(seconds)+" seconds for "+make_human_readable(tests)+" tests.")
    return

# search method 1 will try using digits as the password.
def search_method_1(num_digits):
    global totalguesses
    result = False
    a=0
    #num_digits = 3    # How many digits to try. 1 = 0 to 9, 2 = 00 to 99, etc.
    starttime = time.time()
    tests = 0
    still_searching = True
    print("Using method 1 and searching for "+str(num_digits)+" digit numbers.")
    while still_searching and a<(10**num_digits):
        ourguess = leading_zeroes(a,num_digits)
        tests = tests + 1
        totalguesses = totalguesses + 1
        if (check_userpass(which_password, ourguess)):
            print ("Success! Password "+str(which_password)+" is " + ourguess)
            still_searching = False   # we can stop now - we found it!
            result = True
        #else:
            #print ("Darn. " + ourguess + " is NOT the password.")
        a=a+1

    seconds = time.time()-starttime
    report_search_time(tests, seconds)
    return result

# search method 2 is a simulation of a letter-style combination lock. Each'wheel' has the
# letters A-Z, a-z and 0-9 on it as well as a blank. The idea is that we have a number of
# wheels for a user name and password and we try each possible combination.
def search_method_2(num_pass_wheels):
    global totalguesses
    result = False
    starttime = time.time()
    tests = 0
    still_searching = True
    print("Using method 2 and searching with "+str(num_pass_wheels)+" password wheels.")
    wheel = " ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
    # we only allow up to 8 wheels for each password for now
    if (num_pass_wheels > 8):
        print("Unable to handle the request. No more than 8 characters for a password")
        still_searching = False
    # set all of the wheels to the first position
    pass_wheel_array=array('i',[1,0,0,0,0,0,0,0,0])
        
    while still_searching:
        ourguess_pass = ""
        for i in range(0,num_pass_wheels):  # once for each wheel
            if pass_wheel_array[i] > 0:
                ourguess_pass = wheel[pass_wheel_array[i]] + ourguess_pass
        #print ("trying ["+ourguess_pass+"]")
        if (check_userpass(which_password, ourguess_pass)):
            print ("Success! Password  "+str(which_password)+" is " + ourguess_pass)
            still_searching = False   # we can stop now - we found it!
            result = True
        #else:
            #print ("Darn. " + ourguess + " is NOT the password.")
        tests = tests + 1
        totalguesses = totalguesses + 1
# spin the rightmost wheel and if it changes, spin the next one over and so on
        carry = 1
        for i in range(0,num_pass_wheels): # once for each wheel
            pass_wheel_array[i] = pass_wheel_array[i] + carry
            carry = 0
            if pass_wheel_array[i] > 62:
                pass_wheel_array[i] = 1
                carry = 1
                if i == (num_pass_wheels-1):
                    still_searching = False

    seconds = time.time()-starttime
    report_search_time(tests, seconds)
    return result

# This function takes in numbers, rounds them to the nearest integer and puts
# commas in to make it more easily read by humans
def make_human_readable(n):
    if n>=1:
        result = ""
        temp=str(int(n+0.5))
        while temp != "":
            result = temp[-3:] + result
            temp = temp[:-3]
            if temp != "":
                result = "," + result
    else:
        temp = int(n*100)
        temp = temp /100
        result = str(temp)
    return result
        
## A little helper program to remove any weird formatting in the file
def cleanup (s):
    s = s.strip()
    return s

## A little helper program that capitalizes the first letter of a word
def Cap (s):
    s = s.upper()[0]+s[1:]
    return s


# search method 3 uses a list of dictionary words. In this case, we have a list
# of the 500 most commonly used passwords in 2005 as collected by Mark Burnett
# for his book "Perfect Passwords" (ISBN 978-1597490412). Because the list comes
# from so many people around the world, we had to remove some of the passwords.
# People like to use passwords that they think will shock other people, so
# sometimes they're not fit for polite company.
def search_method_3(file_name):
    global totalguesses
    result = False
    
    # Start by reading the list of words into a Python list
    f = open(file_name)
    words = f.readlines()
    f.close
    # We need to know how many there are
    number_of_words = len(words)
    print("Using method 3 with "+str(number_of_words)+" in the list")
    
    ## Depending on the file system, there may be extra characters before
    ## or after the words. 
    for i in range(0, number_of_words):
        words[i] = cleanup(words[i])

    # Let's try each one as the password and see what happens
    starttime = time.time()
    tests = 0
    still_searching = True
    word1count = 0           # Which word we'll try next

    while still_searching:
        ourguess_pass = words[word1count]
        #print("Guessing: "+ourguess_pass)
        # Try it the way it is in the word list
        if (check_userpass(which_password, ourguess_pass)):
            print ("Success! Password "+str(which_password)+" is " + ourguess_pass)
            still_searching = False   # we can stop now - we found it!
            result = True
        #else:
            #print ("Darn. " + ourguess_pass + " is NOT the password.")
        tests = tests + 1
        totalguesses = totalguesses + 1
        # Now let's try it with the first letter capitalized
        if still_searching:
            ourguess_pass = Cap(ourguess_pass)
            #print("Guessing: "+ourguess_pass)
            if (check_userpass(which_password, ourguess_pass)):
                print ("Success! Password "+str(which_password)+" is " + ourguess_pass)
                still_searching = False   # we can stop now - we found it!
                result = True
            #else:
                #print ("Darn. " + ourguess_pass + " is NOT the password.")
            tests = tests + 1
            totalguesses = totalguesses + 1

        word1count = word1count + 1
        if (word1count >=  number_of_words):
            still_searching = False

    seconds = time.time()-starttime
    report_search_time(tests, seconds)
    return result
            
## Search method 4 is similar to 3 in that it uses the dictionary, but it tries two
## two words separated by a punctuation character
def search_method_4(file_name):
    global totalguesses
    result = False
    
    # Start by reading the list of words into a Python list
    f = open(file_name)
    words = f.readlines()
    f.close
    # We need to know how many there are
    number_of_words = len(words)
    
    ## Depending on the file system, there may be extra characters before
    ## or after the words. 
    for i in range(0, number_of_words):
        words[i] = cleanup(words[i])

    # Let's try each one as the password and see what happens
    starttime = time.time()
    tests = 0
    still_searching = True
    word1count = 0           # Which word we'll try next
    punc_count = 0
    word2count = 0

    punctuation="~!@#$%^&*()_-+={}[]:<>,./X"  # X is a special case where we omit
                                              # the punctuation to run the words together

    number_of_puncs = len(punctuation)
    print("Using method 4 with "+str(number_of_puncs)+" punc chars and "+str(number_of_words)+" in the list")

    while still_searching:
        if ("X" == punctuation[punc_count]):
            # If we're at the end of the string and found the 'X', leave it out
            ourguess_pass = words[word1count] + words[word2count]
        else:
            ourguess_pass = words[word1count] + punctuation[punc_count] + words[word2count]
        #print("Guessing: "+ourguess_pass)
        # Try it the way they are in the word list
        if (check_userpass(which_password, ourguess_pass)):
            print ("Success! Password "+str(which_password)+" is " + ourguess_pass)
            still_searching = False   # we can stop now - we found it!
            result = True
        #else:
            #print ("Darn. " + ourguess_pass + " is NOT the password.")
        tests = tests + 1
        totalguesses = totalguesses + 1
        # Now let's try it with the first letter of the first word capitalized
        if still_searching:
            ourguess_pass = Cap(words[word1count]) + punctuation[punc_count] + words[word2count]
            #print("Guessing: "+ourguess_pass)
            if (check_userpass(which_password, ourguess_pass)):
                print ("Success! Passwword "+str(which_password)+" is " + ourguess_pass)
                still_searching = False   # we can stop now - we found it!
                result = True
            #else:
                #print ("Darn. " + ourguess_pass + " is NOT the password.")
            tests = tests + 1
            totalguesses = totalguesses + 1
        # Now let's try it with the first letter of the second word capitalized
        if still_searching:
            ourguess_pass = words[word1count] + punctuation[punc_count] + Cap(words[word2count])
            #print("Guessing: "+ourguess_pass)
            if (check_userpass(which_password, ourguess_pass)):
                print ("Success! Password "+str(which_password)+" is " + ourguess_pass)
                still_searching = False   # we can stop now - we found it!
                result = True
            #else:
                #print ("Darn. " + ourguess_pass + " is NOT the password.")
            tests = tests + 1
            totalguesses = totalguesses + 1
        # Now let's try it with the both words capitalized
        if still_searching:
            ourguess_pass = Cap(words[word1count]) + punctuation[punc_count] + Cap(words[word2count])
            #print("Guessing: "+ourguess_pass)
            if (check_userpass(which_password, ourguess_pass)):
                print ("Success! Password "+str(which_password)+" is " + ourguess_pass)
                still_searching = False   # we can stop now - we found it!
                result = True
            #else:
                #print ("Darn. " + ourguess_pass + " is NOT the password.")
            tests = tests + 1
            totalguesses = totalguesses + 1

        word1count = word1count + 1
        if (word1count >=  number_of_words):
            word1count = 0
            punc_count = punc_count + 1
            if (punc_count >= number_of_puncs):
                punc_count = 0
                word2count = word2count + 1
                if (word2count >= number_of_words):
                    still_searching = False

    seconds = time.time()-starttime
    report_search_time(tests, seconds)
    return result


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
    # IMPORTANT
    # MD5Me("test") does not work either
    # IMPORTANT
    password0 = "test"
    # 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"

    # start searching
    which_password = 1
    which_password = int(input("Which password (0-6)? "))
    overallstart = time.time()
    foundit = False
    print("Trying to guess password "+str(which_password))
    # 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)
    # 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? 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")

print ("Science Buddies: How Easily Can Your password Be Hacked?")
if __name__ == "__main__":
    sys.exit(main(sys.argv[1:]))
HowardE
Posts: 496
Joined: Thu Nov 20, 2014 1:35 pm
Occupation: Science Buddies content developer
Project Question: N/A
Project Due Date: N/A
Project Status: Not applicable

Re: URGENT! Python problems.

Post by HowardE »

I can try the code you posted tonight but in the meantime, can you post the console output of the crash? Your code looks fine. The output might tell me whAt the problem is.

Howard
cargupta
Posts: 6
Joined: Sun Jan 24, 2016 10:45 am
Occupation: Student

Re: URGENT! Python problems.

Post by cargupta »

HowardE wrote:I can try the code you posted tonight but in the meantime, can you post the console output of the crash? Your code looks fine. The output might tell me whAt the problem is.

Howard
No output in python. It freezes up and gives me the 'not responding' message.
HowardE
Posts: 496
Joined: Thu Nov 20, 2014 1:35 pm
Occupation: Science Buddies content developer
Project Question: N/A
Project Due Date: N/A
Project Status: Not applicable

Re: URGENT! Python problems.

Post by HowardE »

Hi again cargupta-

I don't have anything to suggest except that you put some print() statements in the code in strategic places. Put one before you do a method search, put a bunch in the search and one afterwards. It will slow the program down tremendously but it should at least tell you where things are going wrong.

I pasted the code you provided into an empty file and ran it with Python 3.4.2 on a Windows machine. I got:

>>> ================================ RESTART ================================
>>>
Science Buddies: How Easily Can Your password Be Hacked?
Which password (0-6)? 0
Trying to guess password 0
Using method 1 and searching for 1 digit numbers.
The search took 0.0 seconds for 10 tests.
Using method 1 and searching for 2 digit numbers.
The search took 0.0 seconds for 100 tests.
Using method 1 and searching for 3 digit numbers.
The search took 0.01 seconds for 1,000 tests or 64,009 tests per second.
Using method 1 and searching for 4 digit numbers.
The search took 0.03 seconds for 10,000 tests or 319,978 tests per second.
Using method 3 with 435 in the list
Success! Password 0 is test
The search took 0.01 seconds for 45 tests or 2,880 tests per second.
The total search for all methods took 0.07 seconds and 11,155 guesses.(142,784 guesses per second)
Your algorithm correctly guessed the password you entered. Try some others or see if you can make it guess faster.
>>>

It tried numbers of 1, 2, 3 and 4 digits, then it found the word "test" in the password list file. No matter what I would have expected you to at least see the messages saying it failed the single digit number test.

Just to make sure, you made the change to the code, changing "314" to "test", then went into IDLE and loaded your code, then ran it?

Très mystérieux.

Howard
cargupta
Posts: 6
Joined: Sun Jan 24, 2016 10:45 am
Occupation: Student

Re: URGENT! Python problems.

Post by cargupta »

I have done so. I'm gonna shoot a guess that either my python version is wrong, OR python hates linux. :roll:
cargupta
Posts: 6
Joined: Sun Jan 24, 2016 10:45 am
Occupation: Student

Re: URGENT! Python problems.

Post by cargupta »

Also, when did you start coding/developing? :idea:
HowardE
Posts: 496
Joined: Thu Nov 20, 2014 1:35 pm
Occupation: Science Buddies content developer
Project Question: N/A
Project Due Date: N/A
Project Status: Not applicable

Re: URGENT! Python problems.

Post by HowardE »

I don't have a suggestion then why your installation would just lock up like that. This code has been seen working in Python 3.3 on Ubuntu, Debian (on a Raspberry Pi), a Mac, and in Python 3.4 on a Mac and in Windows. People have had weird effects when they downloaded the code and tabification got damaged, but the problem you're describing is just weird. Is there any chance you can try it on another Python installation? The platform shouldn't matter. I havent yet tried it in Python 3.5 but I can't imagine there will be any issues.

I had never seen Python before a few years ago. One thing about languages is that they all mostly do the same thing - if you know that one language can read files from a disk, a new one can too. It's fairly easy to adapt to new ones if you have good books and reference material, and of course good examples to look at from the web. I do tend to work more on tiny processors in assembly. I wrote my first program in 1971 on an HP programmable calculator (HP 9810) and programming *something* has been part of my schooling and engineering work since then.
cargupta
Posts: 6
Joined: Sun Jan 24, 2016 10:45 am
Occupation: Student

Re: URGENT! Python problems.

Post by cargupta »

I've dabbled in assembly, and it is easy to learn a new language. And yes basically all languages come down to binary which writes to the memory/hard disk. I can run Python 1-3.* on any Windows, Mac, or Linux Distribution. I have access to all of these. I will run controlled tests in Oracle VMBox and on the computers themselves, I will provide specs, output logs/crash logs, and the procedure I used. Hopefully I can find a solution before District Science Fair.

- CarGupta :D
HowardE
Posts: 496
Joined: Thu Nov 20, 2014 1:35 pm
Occupation: Science Buddies content developer
Project Question: N/A
Project Due Date: N/A
Project Status: Not applicable

Re: URGENT! Python problems.

Post by HowardE »

Hi again cargupta-

I wasn't suggesting that languages are all similar because they all run in binary. What i meant was that you can generally assume that languages can read/write disk files, store things in arrays, have some form of control loop that iterates a certain number of times, etc. If you go to learn a new language you can often search for "how do I create empty string arrays in Python" or "how do I get a square root in APL" and find the answer. There's a website with the "Hello World" program written in 200 languages - http://c2.com/cgi/wiki?HelloWorldInMany ... gLanguages If you've never seen this, or '99 bottles of beer' in 1500 variations of 600 languages: http://www.99-bottles-of-beer.net/abc.html

In any case...

The problem you're having with crashing is not related to the code you downloaded here, but rather an issue somehow with your Python installation. Python running in IDLE will not freeze - you can always stop the interpreter by hitting ctrl-C. The code as downloaded also prints stuff to the console. You didn't see that so there's clearly something wrong.

There's an online resource for running code at https://www.repl.it . You can pick one of several languages and run code on their machine. It's pretty cool and very useful. The only reason you can't run the code we provided on that resource is the password file. They don't allow you access to the file system for reading data files. I took the 'crack2.py' file and made a version of it that has the word list stored in a Python function. Instead of reading the text file with 'readlines', it simply shoves the same word list into an array of strings. The code is otherwise identical. You can run it there and you shouldnt have any issues. This is the link to the version I've shared with you: https://www.repl.it/BiQV/0

This is the modified code. It has the file access removed and it also messes with the way main() is launched but that's also nothing.

Code: Select all

#!/usr/bin/python

# This program is offered for use with the Science Buddies project idea
# "How Easily Can Your Password Be Hacked?" which lets you explore the
# makeup of a good password. This program will help you understand some
# methods that people use to guess other people's passwords.
#
# the program begins execution at 'main' after the helper programs and functions
# are defined. You'll also notice that several functions have places where 
# print() functions have been turned into comments. When debugging a program, it's
# helpful to add in more descriptive screen output than you might want later on.
# Once the program is working, you can remove the extra output os, as we've done here,
# 'comment it out' so that someone else can use it again later on if they decide to 
# modify your program.

#Tell Python we want to use some functions it doesn't always use
import sys, time, hashlib
from array import *

#--------------- global variables we expect will be used by any function -----------
#
# a number from 1 to 6 selects which password we'll be trying to guess from
# a selection below.
which_password = 0

# the user names and password we're trying to 'crack'. These will get written
password0 = ""
password1 = ""
password2 = ""
password3 = ""
password4 = ""
password5 = ""
password6 = ""

# repl.it won't let us load in a text file, so we'll define an array of
# empty strings and then fill it with the word list in main() before
# we get started. If you add words to the list by putting more in fill_list()
# BE CERTAIN that you increase the range here.
words = ["" for x in range(435)]


# total number of guesses we had to make to find it
totalguesses = 0


#--------------- extra helper functions -------------------
# These will be used by our search routines later on. We'll get these defined and out
# of the way. The actual search program is called "main" and will be the last one
# defined. Once it's defined, the last statement in the file runs it.
#
#


## Convert a string into MD5 hash
def MD5me(s):
    result = s.encode("utf-8")
    result = hashlib.md5(result).hexdigest()
    return result

# Takes a number from 0 on up and the number of digits we want it to have. It uses that
# number of digits to make a string like "0000" if we wanted 4 or "00000" if we wanted
# 5, converts our input number to a character string, sticks them together and then returns
# the number we started with, with extra zeroes stuck on the beginning. 
def leading_zeroes(n, zeroes):
    t=("0"*zeroes)+str(n)
    t=t[-zeroes:]
    return t

# check_userpass
def check_userpass(which_password, password):
    global password0, password1, password2, password3
    global password4, password5, password6
    
    result = False

    if (0 == which_password):
        if password == password0:
            result = True

    if (1 == which_password):
        if MD5me(password) == password1:
            result = True

    if (2 == which_password):
        if (MD5me(password) == password2):
            result = True

    if (3 == which_password):
        if (MD5me(password) == password3):
            result = True

    if (4 == which_password):
        if (MD5me(password) == password4):
            result = True
            
    if (5 == which_password):
        if (MD5me(password) == password5):
            result = True
            
    if (6 == which_password):
        if (MD5me(password) == password6):
            result = True
            
    return result

# This displays the results of a search including tests per second when possible
def report_search_time(tests, seconds):
    if (seconds > 0.000001):
        print ("The search took "+make_human_readable(seconds)+" seconds for "+make_human_readable(tests)+" tests or "+make_human_readable(tests/seconds)+" tests per second.")
    else:
        print ("The search took "+make_human_readable(seconds)+" seconds for "+make_human_readable(tests)+" tests.")
    return

# search method 1 will try using digits as the password.
def search_method_1(num_digits):
    global totalguesses
    result = False
    a=0
    #num_digits = 3    # How many digits to try. 1 = 0 to 9, 2 = 00 to 99, etc.
    starttime = time.time()
    tests = 0
    still_searching = True
    print("Using method 1 and searching for "+str(num_digits)+" digit numbers.")
    while still_searching and a<(10**num_digits):
        ourguess = leading_zeroes(a,num_digits)
        tests = tests + 1
        totalguesses = totalguesses + 1
        if (check_userpass(which_password, ourguess)):
            print ("Success! Password "+str(which_password)+" is " + ourguess)
            still_searching = False   # we can stop now - we found it!
            result = True
        #else:
            #print ("Darn. " + ourguess + " is NOT the password.")
        a=a+1

    seconds = time.time()-starttime
    report_search_time(tests, seconds)
    return result

# search method 2 is a simulation of a letter-style combination lock. Each'wheel' has the
# letters A-Z, a-z and 0-9 on it as well as a blank. The idea is that we have a number of
# wheels for a user name and password and we try each possible combination.
def search_method_2(num_pass_wheels):
    global totalguesses
    result = False
    starttime = time.time()
    tests = 0
    still_searching = True
    print("Using method 2 and searching with "+str(num_pass_wheels)+" password wheels.")
    wheel = " ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
    # we only allow up to 8 wheels for each password for now
    if (num_pass_wheels > 8):
        print("Unable to handle the request. No more than 8 characters for a password")
        still_searching = False
    # set all of the wheels to the first position
    pass_wheel_array=array('i',[1,0,0,0,0,0,0,0,0])
        
    while still_searching:
        ourguess_pass = ""
        for i in range(0,num_pass_wheels):  # once for each wheel
            if pass_wheel_array[i] > 0:
                ourguess_pass = wheel[pass_wheel_array[i]] + ourguess_pass
        #print ("trying ["+ourguess_pass+"]")
        if (check_userpass(which_password, ourguess_pass)):
            print ("Success! Password  "+str(which_password)+" is " + ourguess_pass)
            still_searching = False   # we can stop now - we found it!
            result = True
        #else:
            #print ("Darn. " + ourguess + " is NOT the password.")
        tests = tests + 1
        totalguesses = totalguesses + 1
# spin the rightmost wheel and if it changes, spin the next one over and so on
        carry = 1
        for i in range(0,num_pass_wheels): # once for each wheel
            pass_wheel_array[i] = pass_wheel_array[i] + carry
            carry = 0
            if pass_wheel_array[i] > 62:
                pass_wheel_array[i] = 1
                carry = 1
                if i == (num_pass_wheels-1):
                    still_searching = False

    seconds = time.time()-starttime
    report_search_time(tests, seconds)
    return result

# This function takes in numbers, rounds them to the nearest integer and puts
# commas in to make it more easily read by humans
def make_human_readable(n):
    if n>=1:
        result = ""
        temp=str(int(n+0.5))
        while temp != "":
            result = temp[-3:] + result
            temp = temp[:-3]
            if temp != "":
                result = "," + result
    else:
        temp = int(n*100)
        temp = temp /100
        result = str(temp)
    return result
        
## A little helper program to remove any weird formatting in the file
def cleanup (s):
    s = s.strip()
    return s

## A little helper program that capitalizes the first letter of a word
def Cap (s):
    s = s.upper()[0]+s[1:]
    return s


# search method 3 uses a list of dictionary words. In this case, we have a list
# of the 500 most commonly used passwords in 2005 as collected by Mark Burnett
# for his book "Perfect Passwords" (ISBN 978-1597490412). Because the list comes
# from so many people around the world, we had to remove some of the passwords.
# People like to use passwords that they think will shock other people, so
# sometimes they're not fit for polite company.
def search_method_3(file_name):
    global totalguesses
    global words
    result = False
    
    # Start by reading the list of words into a Python list
#    f = open(file_name)
#    words = f.readlines()
#    f.close
# (we did this earlier!!)
    # We need to know how many there are
    number_of_words = len(words)
    print("Using method 3 with "+str(number_of_words)+" in the list")
    
    ## Depending on the file system, there may be extra characters before
    ## or after the words. 
    for i in range(0, number_of_words):
        words[i] = cleanup(words[i])

    # Let's try each one as the password and see what happens
    starttime = time.time()
    tests = 0
    still_searching = True
    word1count = 0           # Which word we'll try next

    while still_searching:
        ourguess_pass = words[word1count]
        #print("Guessing: "+ourguess_pass)
        # Try it the way it is in the word list
        if (check_userpass(which_password, ourguess_pass)):
            print ("Success! Password "+str(which_password)+" is " + ourguess_pass)
            still_searching = False   # we can stop now - we found it!
            result = True
        #else:
            #print ("Darn. " + ourguess_pass + " is NOT the password.")
        tests = tests + 1
        totalguesses = totalguesses + 1
        # Now let's try it with the first letter capitalized
        if still_searching:
            ourguess_pass = Cap(ourguess_pass)
            #print("Guessing: "+ourguess_pass)
            if (check_userpass(which_password, ourguess_pass)):
                print ("Success! Password "+str(which_password)+" is " + ourguess_pass)
                still_searching = False   # we can stop now - we found it!
                result = True
            #else:
                #print ("Darn. " + ourguess_pass + " is NOT the password.")
            tests = tests + 1
            totalguesses = totalguesses + 1

        word1count = word1count + 1
        if (word1count >=  number_of_words):
            still_searching = False

    seconds = time.time()-starttime
    report_search_time(tests, seconds)
    return result
            
## Search method 4 is similar to 3 in that it uses the dictionary, but it tries two
## two words separated by a punctuation character
def search_method_4(file_name):
    global totalguesses
    global words
    result = False
    
    # Start by reading the list of words into a Python list
#    f = open(file_name)
#    words = f.readlines()
#    f.close
# (we did this earlier!!)

    # We need to know how many there are
    number_of_words = len(words)
    
    ## Depending on the file system, there may be extra characters before
    ## or after the words. 
    for i in range(0, number_of_words):
        words[i] = cleanup(words[i])

    # Let's try each one as the password and see what happens
    starttime = time.time()
    tests = 0
    still_searching = True
    word1count = 0           # Which word we'll try next
    punc_count = 0
    word2count = 0

    punctuation="~!@#$%^&*()_-+={}[]:<>,./X"  # X is a special case where we omit
                                              # the punctuation to run the words together

    number_of_puncs = len(punctuation)
    print("Using method 4 with "+str(number_of_puncs)+" punc chars and "+str(number_of_words)+" in the list")

    while still_searching:
        if ("X" == punctuation[punc_count]):
            # If we're at the end of the string and found the 'X', leave it out
            ourguess_pass = words[word1count] + words[word2count]
        else:
            ourguess_pass = words[word1count] + punctuation[punc_count] + words[word2count]
        #print("Guessing: "+ourguess_pass)
        # Try it the way they are in the word list
        if (check_userpass(which_password, ourguess_pass)):
            print ("Success! Password "+str(which_password)+" is " + ourguess_pass)
            still_searching = False   # we can stop now - we found it!
            result = True
        #else:
            #print ("Darn. " + ourguess_pass + " is NOT the password.")
        tests = tests + 1
        totalguesses = totalguesses + 1
        # Now let's try it with the first letter of the first word capitalized
        if still_searching:
            ourguess_pass = Cap(words[word1count]) + punctuation[punc_count] + words[word2count]
            #print("Guessing: "+ourguess_pass)
            if (check_userpass(which_password, ourguess_pass)):
                print ("Success! Passwword "+str(which_password)+" is " + ourguess_pass)
                still_searching = False   # we can stop now - we found it!
                result = True
            #else:
                #print ("Darn. " + ourguess_pass + " is NOT the password.")
            tests = tests + 1
            totalguesses = totalguesses + 1
        # Now let's try it with the first letter of the second word capitalized
        if still_searching:
            ourguess_pass = words[word1count] + punctuation[punc_count] + Cap(words[word2count])
            #print("Guessing: "+ourguess_pass)
            if (check_userpass(which_password, ourguess_pass)):
                print ("Success! Password "+str(which_password)+" is " + ourguess_pass)
                still_searching = False   # we can stop now - we found it!
                result = True
            #else:
                #print ("Darn. " + ourguess_pass + " is NOT the password.")
            tests = tests + 1
            totalguesses = totalguesses + 1
        # Now let's try it with the both words capitalized
        if still_searching:
            ourguess_pass = Cap(words[word1count]) + punctuation[punc_count] + Cap(words[word2count])
            #print("Guessing: "+ourguess_pass)
            if (check_userpass(which_password, ourguess_pass)):
                print ("Success! Password "+str(which_password)+" is " + ourguess_pass)
                still_searching = False   # we can stop now - we found it!
                result = True
            #else:
                #print ("Darn. " + ourguess_pass + " is NOT the password.")
            tests = tests + 1
            totalguesses = totalguesses + 1

        word1count = word1count + 1
        if (word1count >=  number_of_words):
            word1count = 0
            punc_count = punc_count + 1
            if (punc_count >= number_of_puncs):
                punc_count = 0
                word2count = word2count + 1
                if (word2count >= number_of_words):
                    still_searching = False

    seconds = time.time()-starttime
    report_search_time(tests, seconds)
    return result

def fill_list():
    global words
    words[0]="123456"
    words[1]="password"
    words[2]="12345678"
    words[3]="1234"
    words[4]="12345"
    words[5]="dragon"
    words[6]="qwerty"
    words[7]="mustang"
    words[8]="baseball"
    words[9]="master"
    words[10]="michael"
    words[11]="football"
    words[12]="shadow"
    words[13]="monkey"
    words[14]="abc123"
    words[15]="pass"
    words[16]="jordan"
    words[17]="harley"
    words[18]="ranger"
    words[19]="jennifer"
    words[20]="hunter"
    words[21]="2000"
    words[22]="test"
    words[23]="batman"
    words[24]="trustno1"
    words[25]="thomas"
    words[26]="tigger"
    words[27]="robert"
    words[28]="access"
    words[29]="love"
    words[30]="buster"
    words[31]="1234567"
    words[32]="soccer"
    words[33]="hockey"
    words[34]="killer"
    words[35]="george"
    words[36]="andrew"
    words[37]="charlie"
    words[38]="superman"
    words[39]="dallas"
    words[40]="jessica"
    words[41]="pepper"
    words[42]="1111"
    words[43]="austin"
    words[44]="william"
    words[45]="daniel"
    words[46]="golfer"
    words[47]="summer"
    words[48]="heather"
    words[49]="hammer"
    words[50]="yankees"
    words[51]="joshua"
    words[52]="maggie"
    words[53]="enter"
    words[54]="ashley"
    words[55]="thunder"
    words[56]="cowboy"
    words[57]="silver"
    words[58]="richard"
    words[59]="orange"
    words[60]="merlin"
    words[61]="michelle"
    words[62]="corvette"
    words[63]="bigdog"
    words[64]="cheese"
    words[65]="matthew"
    words[66]="121212"
    words[67]="patrick"
    words[68]="martin"
    words[69]="freedom"
    words[70]="ginger"
    words[71]="nicole"
    words[72]="sparky"
    words[73]="yellow"
    words[74]="camaro"
    words[75]="secret"
    words[76]="falcon"
    words[77]="taylor"
    words[78]="111111"
    words[79]="131313"
    words[80]="123123"
    words[81]="hello"
    words[82]="scooter"
    words[83]="please"
    words[84]="porsche"
    words[85]="guitar"
    words[86]="chelsea"
    words[87]="black"
    words[88]="diamond"
    words[89]="nascar"
    words[90]="jackson"
    words[91]="cameron"
    words[92]="654321"
    words[93]="computer"
    words[94]="amanda"
    words[95]="wizard"
    words[96]="xxxxxxxx"
    words[97]="money"
    words[98]="phoenix"
    words[99]="mickey"
    words[100]="bailey"
    words[101]="knight"
    words[102]="iceman"
    words[103]="tigers"
    words[104]="purple"
    words[105]="andrea"
    words[106]="dakota"
    words[107]="aaaaaa"
    words[108]="player"
    words[109]="sunshine"
    words[110]="morgan"
    words[111]="starwars"
    words[112]="boomer"
    words[113]="cowboys"
    words[114]="edward"
    words[115]="charles"
    words[116]="girls"
    words[117]="booboo"
    words[118]="coffee"
    words[119]="bulldog"
    words[120]="ncc1701"
    words[121]="rabbit"
    words[122]="peanut"
    words[123]="john"
    words[124]="johnny"
    words[125]="gandalf"
    words[126]="winter"
    words[127]="brandy"
    words[128]="compaq"
    words[129]="carlos"
    words[130]="tennis"
    words[131]="james"
    words[132]="mike"
    words[133]="brandon"
    words[134]="fender"
    words[135]="anthony"
    words[136]="ferrari"
    words[137]="cookie"
    words[138]="chicken"
    words[139]="maverick"
    words[140]="chicago"
    words[141]="joseph"
    words[142]="diablo"
    words[143]="666666"
    words[144]="willie"
    words[145]="welcome"
    words[146]="chris"
    words[147]="panther"
    words[148]="yamaha"
    words[149]="justin"
    words[150]="banana"
    words[151]="driver"
    words[152]="marine"
    words[153]="angels"
    words[154]="fishing"
    words[155]="david"
    words[156]="maddog"
    words[157]="wilson"
    words[158]="dennis"
    words[159]="captain"
    words[160]="chester"
    words[161]="smokey"
    words[162]="xavier"
    words[163]="steven"
    words[164]="viking"
    words[165]="snoopy"
    words[166]="blue"
    words[167]="eagles"
    words[168]="winner"
    words[169]="samantha"
    words[170]="house"
    words[171]="miller"
    words[172]="flower"
    words[173]="jack"
    words[174]="firebird"
    words[175]="butter"
    words[176]="united"
    words[177]="turtle"
    words[178]="steelers"
    words[179]="tiffany"
    words[180]="zxcvbn"
    words[181]="tomcat"
    words[182]="golf"
    words[183]="bond007"
    words[184]="bear"
    words[185]="tiger"
    words[186]="doctor"
    words[187]="gateway"
    words[188]="gators"
    words[189]="angel"
    words[190]="junior"
    words[191]="thx1138"
    words[192]="boys"
    words[193]="debbie"
    words[194]="spider"
    words[195]="melissa"
    words[196]="burger"
    words[197]="1212"
    words[198]="flyers"
    words[199]="fish"
    words[200]="matrix"
    words[201]="teens"
    words[202]="scooby"
    words[203]="jason"
    words[204]="walter"
    words[205]="boston"
    words[206]="braves"
    words[207]="yankee"
    words[208]="barney"
    words[209]="victor"
    words[210]="tucker"
    words[211]="princess"
    words[212]="mercedes"
    words[213]="5150"
    words[214]="doggie"
    words[215]="zzzzzz"
    words[216]="gunner"
    words[217]="bubba"
    words[218]="2112"
    words[219]="fred"
    words[220]="johnson"
    words[221]="member"
    words[222]="donald"
    words[223]="bigdaddy"
    words[224]="bronco"
    words[225]="voyager"
    words[226]="rangers"
    words[227]="birdie"
    words[228]="trouble"
    words[229]="white"
    words[230]="topgun"
    words[231]="green"
    words[232]="super"
    words[233]="qazwsx"
    words[234]="magic"
    words[235]="lakers"
    words[236]="rachel"
    words[237]="slayer"
    words[238]="scott"
    words[239]="2222"
    words[240]="asdf"
    words[241]="video"
    words[242]="london"
    words[243]="7777"
    words[244]="marlboro"
    words[245]="srinivas"
    words[246]="internet"
    words[247]="action"
    words[248]="carter"
    words[249]="jasper"
    words[250]="monster"
    words[251]="teresa"
    words[252]="jeremy"
    words[253]="11111111"
    words[254]="bill"
    words[255]="crystal"
    words[256]="peter"
    words[257]="beer"
    words[258]="rocket"
    words[259]="theman"
    words[260]="oliver"
    words[261]="prince"
    words[262]="beach"
    words[263]="amateur"
    words[264]="7777777"
    words[265]="muffin"
    words[266]="redsox"
    words[267]="star"
    words[268]="testing"
    words[269]="shannon"
    words[270]="murphy"
    words[271]="frank"
    words[272]="hannah"
    words[273]="dave"
    words[274]="eagle1"
    words[275]="11111"
    words[276]="mother"
    words[277]="nathan"
    words[278]="raiders"
    words[279]="steve"
    words[280]="forever"
    words[281]="angela"
    words[282]="viper"
    words[283]="ou812"
    words[284]="jake"
    words[285]="gregory"
    words[286]="buddy"
    words[287]="whatever"
    words[288]="young"
    words[289]="nicholas"
    words[290]="lucky"
    words[291]="helpme"
    words[292]="jackie"
    words[293]="monica"
    words[294]="midnight"
    words[295]="college"
    words[296]="baby"
    words[297]="brian"
    words[298]="mark"
    words[299]="startrek"
    words[300]="sierra"
    words[301]="leather"
    words[302]="232323"
    words[303]="4444"
    words[304]="beavis"
    words[305]="happy"
    words[306]="sophie"
    words[307]="ladies"
    words[308]="giants"
    words[309]="blonde"
    words[310]="golden"
    words[311]="fire"
    words[312]="sandra"
    words[313]="pookie"
    words[314]="packers"
    words[315]="einstein"
    words[316]="dolphins"
    words[317]="chevy"
    words[318]="winston"
    words[319]="warrior"
    words[320]="sammy"
    words[321]="8675309"
    words[322]="zxcvbnm"
    words[323]="power"
    words[324]="victoria"
    words[325]="asdfgh"
    words[326]="toyota"
    words[327]="travis"
    words[328]="hotdog"
    words[329]="paris"
    words[330]="rock"
    words[331]="extreme"
    words[332]="redskins"
    words[333]="ford"
    words[334]="freddy"
    words[335]="arsenal"
    words[336]="access14"
    words[337]="wolf"
    words[338]="iloveyou"
    words[339]="alex"
    words[340]="florida"
    words[341]="eric"
    words[342]="legend"
    words[343]="movie"
    words[344]="success"
    words[345]="rosebud"
    words[346]="jaguar"
    words[347]="great"
    words[348]="cool"
    words[349]="cooper"
    words[350]="1313"
    words[351]="scorpio"
    words[352]="mountain"
    words[353]="madison"
    words[354]="987654"
    words[355]="brazil"
    words[356]="lauren"
    words[357]="japan"
    words[358]="stars"
    words[359]="apple"
    words[360]="alexis"
    words[361]="aaaa"
    words[362]="bonnie"
    words[363]="peaches"
    words[364]="jasmine"
    words[365]="kevin"
    words[366]="matt"
    words[367]="qwertyui"
    words[368]="danielle"
    words[369]="4321"
    words[370]="4128"
    words[371]="runner"
    words[372]="swimming"
    words[373]="dolphin"
    words[374]="gordon"
    words[375]="casper"
    words[376]="saturn"
    words[377]="gemini"
    words[378]="apples"
    words[379]="august"
    words[380]="3333"
    words[381]="canada"
    words[382]="blazer"
    words[383]="hunting"
    words[384]="kitty"
    words[385]="rainbow"
    words[386]="112233"
    words[387]="arthur"
    words[388]="calvin"
    words[389]="surfer"
    words[390]="samson"
    words[391]="kelly"
    words[392]="paul"
    words[393]="mine"
    words[394]="king"
    words[395]="racing"
    words[396]="5555"
    words[397]="eagle"
    words[398]="newyork"
    words[399]="little"
    words[400]="redwings"
    words[401]="smith"
    words[402]="sticky"
    words[403]="cocacola"
    words[404]="animal"
    words[405]="broncos"
    words[406]="private"
    words[407]="skippy"
    words[408]="marvin"
    words[409]="blondes"
    words[410]="enjoy"
    words[411]="girl"
    words[412]="apollo"
    words[413]="parker"
    words[414]="qwert"
    words[415]="time"
    words[416]="sydney"
    words[417]="women"
    words[418]="voodoo"
    words[419]="juice"
    words[420]="abgrtyu"
    words[421]="777777"
    words[422]="dreams"
    words[423]="maxwell"
    words[424]="music"
    words[425]="rush2112"
    words[426]="russia"
    words[427]="scorpion"
    words[428]="rebecca"
    words[429]="tester"
    words[430]="mistress"
    words[431]="phantom"
    words[432]="billy"
    words[433]="6666"
    words[434]="albert"


def main(argv=None):
    global password0, password1, password2, password3
    global password4, password5, password6, totalguesses
    global which_password

    # Set up our word list without using the passwords.txt file. fill_list()
    # is simply a function that just jams the words from that list into
    # the global array words[[
    fill_list()

    # 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"

    # start searching
    which_password = 1
    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")

print ("Science Buddies: How Easily Can Your password Be Hacked?")
main()
You should be able to launch from that site, modify to your heart's content, run your experiments and finish up your project. It would be interesting to find out what was actually causing Python to crash but it's more important that you get the project done. Good luck and do write back with any problems or (better yet) success! :)

Howard
cargupta
Posts: 6
Joined: Sun Jan 24, 2016 10:45 am
Occupation: Student

Re: URGENT! Python problems.

Post by cargupta »

Thank you! I've been looking for an online IDLE like that. Also, i'm very curious aswell and will be running my tests for those different Operating Systems/Processors.
Locked

Return to “Grades 6-8: Math and Computer Science”