使用python程序从SHA3_512值中恢复密码



我正在尝试使用python程序从这个无盐哈希中恢复密码:11af05af85d7656ee0f2e3260760bccdc2af88dee449f682ab2e367003856166edc045c4164a4d543ea4a43d6dd022d3c290866f2d2a7a92a38400bd3a5f7ab0

我有以下代码,并得到这个错误"TypeError: Unicode-objects must be encoded before hashing"

错误看起来像是来自行(if hashlib.sha3_512(pwCandidate).hexdigest() == pwHashHex:)

import itertools
import time
import hashlib
from binascii import hexlify
import shutil
import os
from Crypto.Hash import SHA3_512
pw = input("Enter Password: ")
pw = pw.encode('utf-8')
pwHashHex = hashlib.sha3_512(pw).hexdigest()
print(pwHashHex)
def tryPassword(pwHashHex):
start = time.time()

chars = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ`~!@#$%^&*()_-+=[{]}|:;'",<.>/?"

attempts = 0

for value in range(1, 9):
for pwCandidate in itertools.product(chars, repeat=value):
attempts += 1
pwCandidate = ''.join(pwCandidate)

if hashlib.sha3_512(pwCandidate).hexdigest() == pwHashHex:
end = time.time()
distance = end - start
return (pwCandidate, attempts, distance)
pwFound, tries, timeAmount = tryPassword(pwHashHex)
print("The password %s was cracked in %s tries and %s seconds!" % (pwFound, tries, timeAmount))

您必须像对原始密码那样对候选密码进行编码。hashlib.sha3_512不接受str参数

if hashlib.sha3_512(pwCandidate.encode()).hexdigest() == pwHashHex:

最新更新