Python version 2

PythonBranch
Matthieu DUVAL 8 years ago
parent 42d349e215
commit bca161e5ec

@ -1,50 +1,64 @@
def main(): # -*- coding: utf-8 -*-
passwordCrypte = "azerty" import time
tabPass =list("a") tempsN_1 = time.time();
print("test",2*2) globalTime = time.time()
found, passTrouve = testPass(True,0,tabPass,passwordCrypte ) nMot = 0
if found == True : def main():
print("Trouvé ! : " + passTrouve) #passwordCrypte = "MatDuv1945"
passwordCrypte = "azerty"
tabChar = list("abcdefghijklmnopqrstuvwxyz") tabPass =list("a")
print("test",2*2)
found, passTrouve = testPass(True,0,tabPass,passwordCrypte)
def testPass(isFirst, pos, tabPass, password ): if found == True :
found = False print("Trouvé ! : " + passTrouve +" en " + str(time.time() - globalTime) + " secondes")
passTrouve = ""
#tabChar = list("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")
for char in tabChar: tabChar = list("abcdefghijklmnopqrstuvwxyz")
tabPass[pos] = char
if "".join(tabPass) == password:
found=True def testPass(isFirst, pos, tabPass, password ):
passTrouve = "".join(tabPass) found = False
return found, passTrouve passTrouve = ""
else: global nMot
print("".join(tabPass) + "\t | " + str(len(tabPass))) global tempsN_1
for char in tabChar:
if isFirst == True and found == False: tabPass[pos] = char
while found != True : nMot = nMot +1;
tabPass = tabPass + list('a') if (time.time() - tempsN_1) > 5 :
found,passTrouve =testPass(False,len(tabPass)-1 , tabPass,password) print("\t\t\t" + str(nMot/(time.time() - tempsN_1)) + "Mots/s \tMot actuel : " + "".join(tabPass));
if found == True : nMot = 0;
found=True tempsN_1 = time.time()
passTrouve = "".join(tabPass) if "".join(tabPass) == password:
return found, passTrouve found=True
passTrouve = "".join(tabPass)
return found, passTrouve
if pos > 0 and found == False: #else:
for char in tabChar : #print("".join(tabPass) + "\t | " + str(len(tabPass)))
tabPass[pos] = char
found, passTrouve =testPass(False,pos-1, tabPass,password)
if found == True : if isFirst == True and found == False:
found=True while found != True:
passTrouve = "".join(tabPass) tabPass = tabPass + list('a')
return found, passTrouve found,passTrouve =testPass(False,len(tabPass)-1 , tabPass,password)
passTrouve = "".join(tabPass) if found == True :
return found , passTrouve found=True
passTrouve = "".join(tabPass)
return found, passTrouve
if __name__ == '__main__' :
main() if pos > 0 and found == False:
for char in tabChar :
tabPass[pos] = char
found, passTrouve =testPass(False,pos-1, tabPass,password)
if found == True :
found=True
passTrouve = "".join(tabPass)
return found, passTrouve
passTrouve = "".join(tabPass)
return found , passTrouve
if __name__ == '__main__' :
main()

Loading…
Cancel
Save