-1
I have a code I made in a few minutes that was supposed to be a "Bruteforce". works, but after 3 characters, it takes too long.
I had some ideas to make it more efficient, such as saving in a variable the password that has already been tested, or in a file. but that wouldn’t make much difference (besides spending too much machine resource). Is there any way to make it more efficient? even a simple password of 3 characters, all minusculas, facilitating in all forms, takes about 25 seconds
from time import time
start = time()
import random
#random.choice(alphabet)
alphabet = 'abcdefghijklmnopqrstuvwxyz'
maxLeng = 5
password = input('Password\n>')
possible = ''
while possible != password:
possible = possible + random.choice(alphabet)
if len(possible)>=maxLeng:
possible=''
if possible == password:
print('The password is: '+str(possible))
end=time()
timet=end-start
print('Found in '+str(int(timet))+' seconds') # "str(int(timet))" para arrendondar o tempo
break
else:
print(possible)
input()
An example of how inefficient it is: my script took 290,518 attempts to find "abc", a well-written script, by someone who knows something about it, took 704 attempts.