The idea is that you enter any passwords/characters and then it tries to find that word that you have entered by trying out different combinations of letters and numbers (it really is pointless huh)
The problem right now is that "pw_guess" only prints out one letter or number at a time. There also appears to be duplicates. For example i found that letter "e" was printed 6 times, though should only print it once.
import random
characters = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
pw = input("Enter a password: \n")
pw_lenght = len(pw)
while True:
for i in range(pw_lenght):
random_character = random.randrange(len(characters))
pw_guess = characters[random_character]
if pw_guess == pw:
print('Password found!\nPassword: ', pw)
exit()
print(pw_guess)
It is suppose to print and try out as many letter/numbers at a time as how many have been entered in to the user input.
For example: You type "password123" to the input. Then it will count how many characters there are in that user input (11 in this example), and starts trying out and printing different combinations of characters. One print should now include 11 random characters. Then at some point it will get right combination and stop.
As said above, now it only prints one character at a time and there are also duplicate characters which i don't want.
I've tried putting just one letter to the user input, and it guessed it right, so otherwise it works fine.
import random
characters = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
pw = input("Enter a password: \n")
pw_lenght = len(pw)
while True:
for i in range(pw_lenght):
random_character = random.randrange(len(characters))
pw_guess = ''.join([characters[random.randrange(len(characters))] for x in range(len(pw))])
if pw_guess == pw:
print('Password found!\nPassword: ', pw)
exit()
print(pw_guess)