So i'm trying to create a password generator. It's pretty simple right now but I want it to be able to make and guess passwords without any limits. Could you look at my code and possibly tell me what i'm doing wrong. Everytime I run my code the compiler keeps saying that "list index is out of range." I also don't think my random function is set up properly.
from random import *
import os
u_pwd = input("Enter a password: ")
pwd = ['0','1','2','3','4','5','6','7','8','9']
pw = 0
outcomes = 10 ** len(u_pwd)
i = 0
possible = list(range(0, 10 ** (len(u_pwd))))
while(pw != int(u_pwd)):
for letter in range(len(u_pwd)):
i = randint(0,len(possible))
pw = possible[i]
print(pw)
print("Cracking Password..... Please wait..... ")
print("Attempt ",i, " of ", outcomes)
os.system("cls")
print("Your password is : ",pw)
if i < 2:
print("This password took ",i," attempt")
else:
print("This password took ",i," attempts")
Any help would be appreciated.
I've tried getting the computer to count from 0 all the way to highest possible number given the lenght of the passowrd that the user puts in. That hasn't worked and i figured it was impracticle considering randomly picking a password is also an option.