Created
March 18, 2017 11:49
-
-
Save mwja/588fec314a803beb7c14a99195ee3f8d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
gss = input("guess? ") | |
def isornot(password): | |
global gss | |
if password == gss: | |
return True | |
else: | |
return False | |
poss = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_-=+[]{}(),./<>?;':@!\"£$%^&#~*" | |
def cnt(char): | |
if char[-1] != poss[-1]: | |
char = char[:-1] + poss[poss.index(char[-1])+1] + char[len(char):] | |
val = char | |
pass | |
elif char == poss[-1]: | |
val = "aa" | |
else: | |
char = char[:-1] + "a" + char[len(char):] | |
val = cnt(char[:-1]) + char[-1] | |
pass | |
return val | |
start = datetime.datetime.now() | |
class Password: | |
def __init__(self, confirmation): | |
self.poss = poss | |
self.confirmation = confirmation | |
self.guess = "aaaaaaaa" | |
def run(self): | |
while not self.confirmation(self.guess): | |
self.guess = cnt(self.guess) | |
print("tried %s, elapsed %i" % (self.guess, (datetime.datetime.now()-start).total_seconds()*1000), end="\r") | |
print("correct at %s, elapsed %i" % (self.guess, (datetime.datetime.now()-start).total_seconds()*1000)) | |
Password(isornot).run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment