作为作业的一部分,我们必须刺激暴力破解来分析密码策略的数学原理。目前,我有一个代码,其中输入 4 位 PIN 码,并且该代码随机输入可能的组合,直到找到设置的 PIN 码。之后,它会显示该过程所花费的时间,但是我还希望它显示破解密码所需的猜测数量。我当前拥有的代码不断打印输入的密码而不是猜测的数量。
import time
start = time.process_time()
import random
number = int(input("Input a number that is a password: "))
guess = 0
while (guess != number):
guess = random.randint(0000,9999)
print(guess)
print("Your Password is " + str(number))
print("The Brute Force Took: ")
print(time.process_time() - start)
print("The Brute Force Guessed the Password in: ")
print(str(guess))
我目前不学习代码,因为这是数学作业,但是我对它很陌生,并且希望将其作为一种爱好,如果有人可以帮助我解决这个关于如何打印猜测数量的问题代码就太棒了!
import time
start = time.process_time()
import random
number = int(input("Input a number that is a password: "))
guess = 0
guesses = 0
while (guess != number):
guess = random.randint(0000,9999)
print(guess)
guesses = guesses+1
print("Your Password is " + str(number))
print("The Brute Force Took: ")
print(time.process_time() - start)
print(f"The Brute Force Guessed the Password in: {guesses} ")
如果您需要更多信息,请发表评论,我会提供帮助:)
在此脚本中,我应该在哪里输入或指出我想要破解的 FB 用户名?
随机导入 导入字符串 def 破解密码(密码): 尝试 = 0 而真实: guess = ''.join(random.choices(string.ascii_letters + string.digits, k=len(密码))) 尝试 += 1 如果猜测==密码: 返回尝试
password = input("请输入破解密码:")
print("破解密码...")
尝试=破解密码(密码)
print(f"密码在 {attempts} 次尝试中被破解。")