Hashing
MD5, SHA, bcrypt.
Hashing is a free Ethical Hacking Academy lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Ethical Hacking Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
What Is a Hash?
A hash function takes input of any size and produces a fixed-size output called a digest. The same input always produces the same digest.
Crucially, hashing is a one-way operation. You cannot mathematically reverse a digest back into the original input. This is what makes hashes different from both encoding and encryption.
Properties of a Good Hash
A cryptographic hash function should be:
- Deterministic: same input gives same output.
- Fast to compute (for general hashing) but ideally slow for password hashing.
- Preimage resistant: given a digest, you cannot find the input.
- Collision resistant: hard to find two inputs with the same digest.
- Avalanche effect: one bit change flips about half the output bits.
MD5
MD5 produces a 128-bit (32 hex character) digest. It is fast and historically common, but it is cryptographically broken: practical collision attacks exist.
Never use MD5 for security. You will still encounter it for file checksums and in legacy systems, which makes it a frequent target during assessments.
echo -n 'password' | md5sum
# 5f4dcc3b5aa765d61d8327deb882cf99The SHA Family
The SHA (Secure Hash Algorithm) family is more robust:
- SHA-1: 160-bit. Now considered broken (collision attack 'SHADOW HAMMER' / SHAttered). Avoid.
- SHA-2: includes SHA-256 and SHA-512. Widely used and currently secure.
- SHA-3: a newer design based on Keccak, an alternative to SHA-2.
echo -n 'password' | sha256sum
# 5e884898da28047151d0e56f8dc629...Hashing Is Not Encryption
Encryption is reversible with a key. Hashing is not reversible at all. This is exactly why hashing is used to store passwords: the server never needs the original.
When you log in, the server hashes what you typed and compares it to the stored hash. If they match, you are authenticated. The plaintext password is never stored.
The Problem: Rainbow Tables
Because hashing is deterministic, the digest of 'password' is the same for every user. Attackers precompute huge lookup tables of digest-to-plaintext called rainbow tables.
If two users share the same password, their stored hashes are identical, leaking that fact. Plain fast hashes like MD5 or SHA-256 alone are unsuitable for passwords.
Salting
A salt is a unique random value added to each password before hashing. This means:
- Identical passwords produce different hashes.
- Precomputed rainbow tables become useless.
The salt is stored alongside the hash; it is not secret. Its job is to make every hash unique, forcing attackers to crack each one individually.
stored = salt + hash(salt + password)
# salt is random and unique per userbcrypt: Built for Passwords
bcrypt is designed specifically for password storage. It is intentionally slow and includes a configurable cost factor (work factor) that makes it slower as hardware improves.
A bcrypt hash embeds the algorithm, cost, and salt in one string. Slowness is a feature: it limits how fast attackers can guess.
$2b$12$R9h/cIPz0gi.URNNX3kh2OPST9/PgBkqquzi.Ss7KIUgO2t0jWMUW
# $2b$ = bcrypt, 12 = cost factor, then salt + hashOther Slow Hashes
Besides bcrypt, modern password hashing options include:
- scrypt: memory-hard, resists GPU and ASIC attacks.
- Argon2: winner of the Password Hashing Competition, tunable for time and memory. The recommended modern choice.
- PBKDF2: applies a fast hash many thousands of iterations; acceptable but weaker than the above.
HMAC and Integrity
Hashes are also used for integrity, not just passwords. An HMAC (Hash-based Message Authentication Code) combines a hash with a secret key to verify both integrity and authenticity of a message.
File checksums (often SHA-256) let you verify a download was not tampered with. As a hacker, mismatched checksums can reveal modified or malicious files.
Hashes in the Wild
As a hacker you constantly meet hashes:
- /etc/shadow on Linux stores salted password hashes, prefixed like
$6$(SHA-512) or$2b$(bcrypt). - Windows stores NTLM hashes in the SAM database.
- Web apps store hashed passwords in their user tables.
Recognizing the prefix instantly tells you the algorithm and your cracking strategy.
$6$rounds=5000$salt$hash # SHA-512 crypt
$2b$12$saltandhash... # bcryptQuick Check
Pick the most secure choice for storing user passwords.
Recap
You now understand hashing:
- Hashing is a one-way, fixed-size, deterministic transformation, different from encoding and encryption.
- MD5 and SHA-1 are broken; use SHA-256 for general integrity.
- For passwords use slow, salted algorithms: bcrypt, scrypt, or Argon2.
- Salts defeat rainbow tables; HMAC adds keyed integrity.
Next you will explore symmetric and asymmetric encryption with AES and RSA.
Frequently asked questions
Is the “Hashing” lesson free?
Yes — the full text of “Hashing” is free to read here on the web, and the Ethical Hacking Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Ethical Hacking Academy course, upgrade to CoddyKit PRO.
What will I learn in “Hashing”?
MD5, SHA, bcrypt. You practise Ethical Hacking Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Ethical Hacking Academy?
No prior experience is required. Ethical Hacking Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Hashing” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Ethical Hacking Academy lesson?
Yes. Every Ethical Hacking Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.