python 中的密码求解器循环计数
password solver loop count in python
我正在 python 中编写一个程序,允许您输入密码,然后 python 遍历所有 ascii 字符以尝试猜测您的密码。我已经让它工作了,但我试图在其中建立一个 运行 的计数,看看计算机猜测这个字符的尝试次数。我只是不确定 运行thru 计算的迭代次数是否正确?欢迎任何建议。
代码如下.....
password=input("Enter a password:")
print("Your password is: ",password)
print("Your password length is: ",len(password))
length=len(password)
crackedlistx=[]
runthrus=0
lengthx=len(crackedlistx)
passwordlist=password.split()
print("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
while length>len(crackedlistx):
for i in range(0,length):
for c in (chr(i) for i in range(0,128)):
runthrus=runthrus+1
if password[i]==c:
crackedlistx.append(c)
runthrus=runthrus+1
print("Finding",len(crackedlistx),"of",length,"characters.")
print("Your password being solved:",crackedlistx)
print("Percentage complete: ",100*(len(crackedlistx)/length),"%")
print("Your final password solved:",''.join(crackedlistx))
print("Run through's taken:",runthrus)
您不需要第二个 runthrus
增量:
...
runthrus=runthrus+1
if password[i]==c:
crackedlistx.append(c)
runthrus=runthrus+1 # delete this line
print("Finding",len(crackedlistx),"of",length,"characters.")
...
此外,您可以将 runthrus=runthrus+1
替换为 runthrus += 1
我正在 python 中编写一个程序,允许您输入密码,然后 python 遍历所有 ascii 字符以尝试猜测您的密码。我已经让它工作了,但我试图在其中建立一个 运行 的计数,看看计算机猜测这个字符的尝试次数。我只是不确定 运行thru 计算的迭代次数是否正确?欢迎任何建议。
代码如下.....
password=input("Enter a password:")
print("Your password is: ",password)
print("Your password length is: ",len(password))
length=len(password)
crackedlistx=[]
runthrus=0
lengthx=len(crackedlistx)
passwordlist=password.split()
print("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
while length>len(crackedlistx):
for i in range(0,length):
for c in (chr(i) for i in range(0,128)):
runthrus=runthrus+1
if password[i]==c:
crackedlistx.append(c)
runthrus=runthrus+1
print("Finding",len(crackedlistx),"of",length,"characters.")
print("Your password being solved:",crackedlistx)
print("Percentage complete: ",100*(len(crackedlistx)/length),"%")
print("Your final password solved:",''.join(crackedlistx))
print("Run through's taken:",runthrus)
您不需要第二个 runthrus
增量:
...
runthrus=runthrus+1
if password[i]==c:
crackedlistx.append(c)
runthrus=runthrus+1 # delete this line
print("Finding",len(crackedlistx),"of",length,"characters.")
...
此外,您可以将 runthrus=runthrus+1
替换为 runthrus += 1