0

I am trying to make code that breaks a password that I create, at first I got it to just make random answers to the password I created and eventually I would get the right one.
But I realized that if I could change the first letter of my answer and then when I had done all of the letters, change the second letter.

Ex: AA AB AC ... AY AZ BA BB BC.

I understand that I could make a loop to print every single letter, but how would I be able to change the first letter after I have gone through every letter.
I also need this to be able to break a password of any length so the loop would have to be able to change how many letters I need. I also need to get rid of the brackets and quotes in the output.

    lower_upper_alphabet = ['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', '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']

while done == 0:

    for i in range (int(passwordlen)):

        for i in range(52):

            for i in range(len(lower_upper_alphabet)):

                characters2 = []

                characters2.append(str(lower_upper_alphabet[next1]))

                next1 += 1

                print(characters2)

Output:

["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"]
Harshit Ruwali
  • 1,040
  • 2
  • 10
  • 22
  • See `itertools.product` – SuperStormer Dec 11 '20 at 17:55
  • See [What is the best way to generate all possible three letter strings?](https://stackoverflow.com/questions/7074051/what-is-the-best-way-to-generate-all-possible-three-letter-strings) for some ideas. – jarmod Dec 11 '20 at 17:55
  • itertools.combinations(iterable, r)------ I think this will be better it will produce every combination and then you can itterate the object and compare or you can get a list of all combination by just doing------ list(itertools.combinations(iterable, r)) – Sachin Rajput Dec 11 '20 at 17:59
  • please post an [mre] what is passwordlen and what is next1 and what is done? – ppwater Dec 12 '20 at 10:23

0 Answers0