đź§© Quick Overview
Repository: Hash-Cracker
Language: Python
We’ve all been there — you’re trying to log into an old account, and you realize you’ve forgotten the password. It’s frustrating, but what if you don’t have the option to reset it and you’re stuck with just the hashed version of your password? Well, that’s exactly what happened to me recently, and I decided to solve it with a little help from Python.
Let me walk you through how I recovered a forgotten password using a simple Python script to crack the hash.
đź’» The Situation
I was going through some old project files and stumbled upon a password manager I made years ago. I had stored the passwords in a database, but here’s the catch — they were all hashed. The password for my admin account was stored as an MD5 hash:
admin_password_hash = ec0e2603172c73a8b644bb9456c1ff6e
This was great back then for keeping things secure (sort of), but now, I couldn’t remember the original password.
I figured that since I knew a handful of passwords I used back in the day — like “batman”, “password123”, and “qwerty” — I could try to crack the hash using a basic technique: brute-force.
🔨 The Hash Cracker Script
Click here to view full python source code
import hashlib
def crack_hash(hash_to_crack, hash_type, wordlist_path):
# Check if the wordlist file can be opened
try:
with open(wordlist_path, 'r') as file:
print("Wordlist file opened successfully.")
except FileNotFoundError:
print(f"File not found: {wordlist_path}")
return
# Start cracking the hash
with open(wordlist_path, 'r') as file:
for word in file:
word = word.strip()
if hash_type == 'md5':
hashed = hashlib.md5(word.encode()).hexdigest()
elif hash_type == 'sha1':
hashed = hashlib.sha1(word.encode()).hexdigest()
elif hash_type == 'sha256':
hashed = hashlib.sha256(word.encode()).hexdigest()
else:
print("Unsupported hash type.")
return
if hashed == hash_to_crack:
print(f"[+] Password found: {word}")
return
print("[-] Password not found in wordlist.")
# Example usage:
# Set the hash type and hash to crack.
# You can change the hash_type and hash_to_crack to any of the supported types.
hash_type = 'md5' # You can change this to 'md5', 'sha1', or 'sha256'
hash_to_crack = 'ec0e2603172c73a8b644bb9456c1ff6e' # Example md5 hash of "batman"
wordlist_path = r"C:\Users\glitc\OneDrive\Desktop\Coding_Projects\hash_cracker\wordlist.txt" # Path to your wordlist file
crack_hash(hash_to_crack, hash_type, wordlist_path)
⚙️ How does it work?
I prepared a wordlist (a simple text file) with my common passwords, like this:

I then ran the script to crack the hash. Here’s how it went:
python hash_cracker.py
And the result?
Wordlist file opened successfully.
[+] Password found: batman

Just like that, I had the original password back!
Why It Matters?
Understanding how to crack a hash using tools like a Python hash cracker is more than just a fun coding challenge — it has real-world applications. Hashing is a fundamental concept in cybersecurity, widely used to protect sensitive information, like passwords. However, when passwords are forgotten, being able to reverse a hash and recover the password can be a game-changer.
The ability to crack hashes helps illustrate the vulnerabilities that might exist in systems that rely solely on hashing without proper security measures, like salting or key stretching. By understanding the mechanics of hash cracking, developers, security professionals, and even everyday users can better appreciate the importance of strong password practices and secure systems.
Whether you’re recovering your own password or learning about password security, this knowledge is essential for building safer digital environments.