Threaded Dictionary Hash-Cracker (hashlib)
Minimal threaded dictionary hash-cracker in pure Python — when you want to script it or match an unusual algorithm instead of reaching for hashcat.
#!/usr/bin/env python3
import hashlib
from concurrent.futures import ThreadPoolExecutor, as_completed
def matches(word, target, algo):
h = hashlib.new(algo); h.update(word.encode())
return h.hexdigest() == target.lower()
def crack(target, wordlist, algo="sha256", workers=8):
with open(wordlist, encoding="utf-8", errors="ignore") as f:
words = [w.strip() for w in f if w.strip()]
with ThreadPoolExecutor(max_workers=workers) as ex:
futs = {ex.submit(matches, w, target, algo): w for w in words}
for fut in as_completed(futs):
if fut.result():
return futs[fut]
return None
if __name__ == "__main__":
print(crack("<target-hash>", "/usr/share/wordlists/rockyou.txt", "md5"))