What is the difference between encryption and hashing?
General knowledgeIn depthAsked by Anonymous23 Oct 2026, 1:18 PM ISTUpdated
In one line
Encryption hides data so only certain people can read it; hashing turns data into a fixed code that cannot be turned back.
Alan Turing — English computer scientist (1912–1954) Alan Turing, who helped break enemy codes and inspired modern encryption. Image: Wikipedia
The rule
Encryption is a process that changes readable data (plaintext) into unreadable data (ciphertext) using a key, so only someone with the key can get the original data back. Hashing is a process that converts data into a fixed-size code (hash value) in such a way that you cannot get the original data back from the code.
There are no simple formulas, but:
Encryption: Ciphertext = Encrypt(Plaintext, Key)
Hashing: Hash Value = Hash(Data)
Let's understand it simply
Imagine you write a secret message to your friend. If you use encryption, you lock the message in a box with a key. Only your friend, who has the key, can open the box and read the message. Anyone else just sees a locked box.
Now, think about hashing. You take your message and put it through a special machine. This machine spits out a unique number or code. But, once the message is inside, you can never get it out again. The code always looks the same for the same message, but you can't turn the code back into the message.
Encryption vs Hashing
Encryption
Hashing
Purpose
Hide data so only some can read it
Check or identify data, not hide it
Can you get the original back?
Yes, with the key
No, never
Used for
Messages, files, bank data
Passwords, file checks, blockchains
Example
WhatsApp chat
Password storage
How it works
Encryption
You choose a message (like "Meet at 5 PM").
You use a secret key and an algorithm (a set of steps) to scramble the message.
The scrambled message (ciphertext) is sent to your friend.
Your friend uses the same (or a matching) key to unscramble it and read the message.
Hashing
You take any data (like a password).
You put it through a hash function (a special formula).
The function gives you a fixed-size code (hash value).
You store or compare this code, but you cannot get the original data back from it.
How encryption and hashing work
Start with data (like a message or password)
For encryption: scramble with a key, can be unscrambled
For hashing: turn into a code, cannot be reversed
The story behind it
Encryption has been used for thousands of years. Ancient Indians used simple ciphers (like shifting letters) to send secret messages in wars. Modern encryption started with computers in the 20th century, especially during World War II, when people like Alan Turing broke enemy codes.
Hashing became important with computers and the internet. In the 1970s, computer scientists needed a way to check if files or passwords matched, without storing the real data. Hashing solved this problem.
Where you see it in real life
Encryption
WhatsApp chats → Your messages are encrypted so only you and your friend can read them.
Online banking → Your account details are encrypted to protect them from hackers.
ATM cards → The PIN you enter is encrypted before being sent to the bank.
Hashing
Password storage → When you set a password, the website stores only the hash, not your real password.
File downloads → Websites give you a hash code to check if your download is correct and not tampered.
Aadhaar authentication → Your fingerprint is hashed before being checked.
Blockchain (like Bitcoin) → Every block uses hashing to link to the next block securely.
Checking exam results → Sometimes, roll numbers are hashed to keep student identities secret.
Why it matters
Encryption keeps your data private and safe from thieves, hackers, or spies.
Hashing helps check if data has changed or is correct, without showing the actual data.
Both are used in almost every app, website, and ATM you use.
Exams like JEE, NEET, and government jobs ask about these in computer science and IT papers.
Worked example
Let's see both with a simple message: "hello"
Encryption:
Given: Message = "hello", Key = 3 (Caesar cipher: shift each letter by 3)
Step 1: h → k, e → h, l → o, l → o, o → r
Step 2: Encrypted message = "khoor"
Step 3: To read, shift back by 3: k → h, h → e, o → l, o → l, r → o
Hashing:
Given: Message = "hello"
Step 1: Use a hash function (like MD5)
Step 2: MD5("hello") = 5d41402abc4b2a76b9719d911017c592
Step 3: You cannot get back "hello" from this code
Common mistakes
Thinking encryption and hashing are the same. They are not: encryption can be reversed with a key, hashing cannot.
Believing you can get the original data back from a hash. You cannot.
Using hashing to keep secrets. Hashing is for checking, not for hiding information.
Forgetting that not all encryption is safe; weak keys can be broken.
Remember it
Encryption = lock and unlock with a key. Hashing = one-way code, no going back.
Check yourself
If you want to keep your WhatsApp messages private, which do you use: encryption or hashing? Why?
Encryption, because only you and your friend can unlock and read the messages.
Can you get your password back from its hash code?
No, hashing is one-way; you cannot get the original password back.
Why do websites store only hashed passwords and not the real ones?
So even if hackers steal the data, they cannot see the real passwords.
What is the main difference between encryption and hashing?
Encryption can be reversed with a key; hashing cannot be reversed.
Quick recap
Encryption hides data and can be reversed with a key.
Hashing turns data into a code that cannot be reversed.
Encryption is for privacy; hashing is for checking or matching.
Both are used in daily apps, banking, and websites.