我已经制作了一个Python程序,可以将您的密码加密为sha256。
import hashlib
u = input("Write 3 upper-case letters: ").upper()
d = int(input("Write 4 digits from 0-9 "))
testhashed = u+str(d)
key = hashlib.sha256(testhashed.encode())
print("function 1" +key.hexdigest())
但是我完全不知道如何制作暴力功能。如果有人可以指导我,将不胜感激。
import hashlib, itertools
def brute_force(hash):
letters = [chr(n) for n in range(ord('A'), ord('Z'))]
digits = [chr(n) for n in range(ord('0'), ord('9'))]
for part1 in itertools.product(letters, repeat=3):
for part2 in itertools.product(digits, repeat=4):
password_try = ''.join(part1 + part2)
if hashlib.sha256(password_try.encode()).hexdigest() == hash:
return password_try
test_password = "BOO8000"
key = hashlib.sha256(test_password.encode()).hexdigest()
print("Hash: %s" % key)
print("Brute-forcing...")
recovered_key = brute_force(key)
print("Brute-force result: %s" % recovered_key)