【发布时间】:2021-02-06 22:30:38
【问题描述】:
我试图找出这个 SHA3-512 哈希值的密码:11af05af85d7656ee0f2e3260760bccdc2af88dee449f682ab2e367003856166edc045c4164a4d543ea4a43d6dd022d3c290866402d2a7afb723a。 我遇到的问题是,当我运行我的代码时,它仍然返回哈希值。我的问题是我需要在我的代码中更改什么来生成密码?这是运行我的代码的结果的一些屏幕截图。
import itertools
import time
import hashlib
from binascii import hexlify
import shutil
import os
data = input("Enter Password:")
data1 = data.encode('utf-8')
sha3_512 = hashlib.sha3_512(data1)
sha3_512_digest = sha3_512.digest()
sha3_512_hex_digest = sha3_512.hexdigest()
print(sha3_512_hex_digest)
# Function to brute force the password
def tryPassword(passwordSet):
start = time.time()
# Allowed characters in the password
chars = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ`~!@#$%^&*()_-+=[{]}|:;'\",<.>/?"
attempts = 0
for value in range(1, 800):
# Build up a string to test against, character by character
for letter in itertools.product(chars, repeat=value):
attempts += 1
letter = ''.join(letter)
#if the string we are building matches the password given to us, return from the function
if letter == passwordSet:
end = time.time()
distance = end - start
return (attempts, distance)
tries, timeAmount = tryPassword(data)
print("The password %s was cracked in %s tries and %s seconds!" % (data, tries, timeAmount))
【问题讨论】:
标签: python-3.x hash python-3.7 sha brute-force