Python version 2

PythonBranch
Matthieu DUVAL 8 years ago
parent 42d349e215
commit bca161e5ec

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