primitive password cracker

David Raymond David.Raymond at tomtom.com
Thu Jan 7 10:18:15 EST 2021


I think you might want to check out itertools.product()
https://docs.python.org/3.9/library/itertools.html#itertools.product
import itertools
import string
passe = 'pass'
for p in itertools.product(string.ascii_lowercase, repeat = 4):
 p = "".join(p)
 if p == passe:
 print("Found it:", p)
 break
else:
 print("Didn't find it.")
Or for different lengths:
foundIt = False
for repeat in range(1, 6):
 for p in itertools.product(string.ascii_lowercase, repeat = repeat):
 p = "".join(p)
 if p == passe:
 print("Found it:", p)
 foundIt = True
 break
 if foundIt:
 break
else:
 print("Didn't find it.")


More information about the Python-list mailing list

AltStyle によって変換されたページ (->オリジナル) /