我的代碼是Python的密碼破解
from random import *
guess = ""
password = input("Password: ")
letters = ["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 (guess != password):
for letter in password:
guessletter = letters[randint(0, 25)]
guess = str(guessletter) + str(guess)
print(guess)
print("Password guessed!")
input("")
我的目標是得到它的隨機生成的字母和把它們粘在一起,使密碼的長度,並做到這一點,直到它找到的密碼。每次我運行它時,它都會使命令提示符看起來像是Matrix的東西。有什麼我做錯了嗎?
P.S.我正在這樣做,看看如何破解密碼。我無意竊聽別人的帳戶。
您正在打印所有猜測,因爲'print(guess)'在while循環中。如果你不想這樣做,不要打印所有的猜測。 –
但是,所有的猜測都不是密碼的長度,即使只有3個字母,也不能猜出密碼。 – RugbugRedfern
我想你想在每個while循環開始時重置你的猜測爲空字符串 –