Python Saved Program: ferrous-terrain

facebook share

Here's the online compiler accompanied with IDE at your service. This is a saved code by one of our users. Try it out or save your own from the IDE page and don't forget to leave a feedback. You can find that at the bottom of the page.


#Password Analyzer  By Anthony Hartup   anthscomputercave.com
#Generate and crack 10 four-character passwords.
import random

characters = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0",\
 "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m",\
 "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
guesses = []
quota = 0

def crack():
    global guesses, quota
    status = "ongoing"
    count = 0
    while status == "ongoing":
        char = [random.choice(characters), random.choice(characters),\
         random.choice(characters), random.choice(characters)]
        guess = char[0] + char[1] + char[2] + char[3]
        if guess == pw:
            print("Password cracked!: ", guess, ",", pw)
            status = "finished"
            count += 1
            print(count)
        else:
            count += 1
    guesses.append(count)
    quota += 1
    print("Quota: ", quota)

while quota < 1:
    pc = [random.choice(characters), random.choice(characters),\
     random.choice(characters), random.choice(characters)]
    pw = pc[0] + pc[1] + pc[2] + pc[3]
    crack()

total = 0
for i in guesses:
    total = total + i
    avg = total / len(guesses)
print(quota, "passwords cracked.")
print("Average: ", avg, "guesses per password.")
	
Execute

Output

Press the execute button or CTRL + enter to run code.

Inputs