Hashing algorithms (MD5, SHA)
🔐 HASHING ALGORITHMS (MD5, SHA)
📘 What is Hashing?
Hashing is the process of converting data (message, file, password) into a fixed-length string of characters using a mathematical algorithm.
The output is called a Hash Value or Message Digest.
⚠ Important:
Hashing is a one-way process — it cannot be reversed.
🎯 Purpose of Hashing
Hashing is mainly used for:
-
Data Integrity
-
Password Storage
-
Digital Signatures
-
File Verification
-
Blockchain technology
🔑 Important Characteristics of Hash Functions
A good hashing algorithm must:
-
Produce fixed-length output
-
Be one-way (irreversible)
-
Be fast to compute
-
Avoid collisions (two inputs should not produce same hash)
-
Show avalanche effect (small input change → big output change)
📌 What is a Collision?
A collision occurs when two different inputs produce the same hash value.
Strong hash functions minimize collisions.
🔢 Example of Hashing
Input:
Hello
MD5 Output:
8b1a9953c4611296a827abf8c47804d7
SHA-256 Output:
185f8db32271fe25f561a6fc938b2e264306ec304eda518007d1764826381969
Notice:
Even a small change in input changes the entire hash.
1️⃣ MD5 (Message Digest Algorithm 5)
📘 Definition
MD5 is a widely used cryptographic hash function that produces a 128-bit hash value.
Developed by Ronald Rivest in 1991.
🔑 Features
-
Produces 128-bit hash
-
Output length: 32 hexadecimal characters
-
Fast processing
-
Now considered insecure
❌ Weakness of MD5
-
Vulnerable to collision attacks
-
Not secure for passwords
-
Not recommended for cryptographic security
✅ Current Uses (Limited)
-
File integrity checks
-
Non-security applications
2️⃣ SHA (Secure Hash Algorithm)
📘 Definition
SHA is a family of cryptographic hash functions developed by NIST (National Institute of Standards and Technology).
🔥 SHA Family
1️⃣ SHA-1
-
160-bit hash
-
Now insecure
-
Vulnerable to collisions
2️⃣ SHA-2 (Most Common Today)
Includes:
-
SHA-224
-
SHA-256
-
SHA-384
-
SHA-512
Most popular: SHA-256
3️⃣ SHA-3
-
Latest version
-
More secure structure
-
Different algorithm design
🔑 SHA-256 Features
-
Produces 256-bit hash
-
Very secure
-
Used in blockchain
-
Used in SSL/TLS
-
Used in digital certificates
🔥 MD5 vs SHA Comparison
| Feature | MD5 | SHA-1 | SHA-256 |
|---|---|---|---|
| Output Size | 128-bit | 160-bit | 256-bit |
| Security | Weak | Weak | Strong |
| Speed | Fast | Moderate | Slightly slower |
| Collision Resistance | Poor | Weak | Strong |
| Recommended Today | ❌ No | ❌ No | ✅ Yes |
🔐 Hashing vs Encryption
| Feature | Hashing | Encryption |
|---|---|---|
| Reversible | No | Yes |
| Uses Key | No | Yes |
| Purpose | Data integrity | Data confidentiality |
| Example | SHA-256 | AES |
🛡 Real-Life Applications of SHA-256
-
Password storage
-
Blockchain (Bitcoin)
-
SSL certificates
-
Digital signatures
-
Secure file verification
🎯 Why MD5 and SHA-1 Are Not Secure?
-
Advanced computing can find collisions.
-
Hackers can generate fake certificates.
-
Password cracking tools can break weak hashes.
Therefore, modern systems use:
-
SHA-256
-
SHA-3
-
Bcrypt
-
PBKDF2
🎓 Exam Important Short Note
Hashing algorithms like MD5 and SHA convert data into fixed-length hash values to ensure data integrity. MD5 produces a 128-bit hash but is insecure, while SHA-256 produces a 256-bit hash and is widely used for secure applications.
Comments
Post a Comment