Have you ever clicked "Forgot Password" on a website, expecting them to email your old password back to you, only for them to force you to create a brand-new one instead?
There is a very good reason for that: a well-designed website does not actually know your password.
In cybersecurity, beginners often mix up Encryption and Hashing. Both turn readable text into scrambled characters, so they look similar on the surface. Under the hood, however, they solve completely different problems.
1. Encryption: The Locked Box (Two-Way)
Encryption is a two-way process. You lock (encrypt) data using a secret key so it can travel safely across the internet, with the full intention of unlocking (decrypting) it back into its original form later.
The Goal: Confidentiality (keeping data secret while moving or storing it).
Key Requirement: Requires a key to encrypt and a key to decrypt.
Common Uses: HTTPS web traffic, WhatsApp end-to-end encrypted chats, and securing bank transactions.
2. Hashing: The Meat Grinder (One-Way)
Hashing is strictly a one-way mathematical function. You feed any piece of data—whether it is a 6-letter password or a 500-page PDF—into a hashing algorithm (like SHA-256 or bcrypt), and it spits out a fixed-length string of random-looking characters called a Hash Digest.
Think of hashing like putting a potato into a blender to make soup. You can easily turn a potato into soup, but you can never turn the soup back into the original potato. There is no "un-hash" button and no decryption key.
The Goal: Data integrity and safe password verification.
Key Requirement: No key is needed to generate a standard hash.
Common Uses: Storing passwords in databases, verifying file downloads, and powering digital signatures.
How Does a Website Log You In Without Knowing Your Password?
When you create an account on Instagram or Gmail, the server immediately runs your password through a hashing algorithm and saves only the hash in its database.
The next time you type your password to log in:
The server takes what you just typed and runs it through the exact same hashing algorithm.
It compares the new hash with the saved hash in the database.
If the two hashes match character-for-character, the server knows you typed the right password and lets you in.
If a hacker ever breaks into the company's database, they only steal a list of unreadable hashes—not your actual passwords.
What About "Salting"?
If two users happen to pick the exact same password (like India@2026), a basic hash function would produce the exact same hash for both of them. Hackers exploit this using pre-computed cheat sheets called Rainbow Tables.
To stop this, modern systems use Salting: they add a unique, random string of characters (the "salt") to your password before hashing it. Even if two people use the exact same password, their stored hashes look completely different.
Quick Comparison: Hashing vs. Encryption
| Feature | Encryption | Hashing |
| Direction | Two-way (Reversible) | One-way (Irreversible) |
| Uses a Key? | Yes (Symmetric or Asymmetric) | No |
| Output Length | Grows with the size of the input | Always a fixed length |
| Common Algorithms | AES, RSA, ChaCha20 | SHA-256, bcrypt, Argon2 |
| Primary Purpose | Protecting data in transit or storage | Password storage & integrity checks |
If a website ever emails you your actual password in plain text when you click "Forgot Password," change your password immediately—it means they are not hashing their database properly.

No comments:
Post a Comment