🧮 1. Basic Details

FeatureMD5SHA-1
Full FormMessage Digest 5Secure Hash Algorithm 1
Developed ByRonald Rivest (1991)NSA (1995), published by NIST
Output Size128 bits (32 hex chars)160 bits (40 hex chars)
Block Size512 bits512 bits
SpeedFasterSlightly slower

🔐 2. Security

AspectMD5SHA-1
Collision ResistanceWeak (collisions found easily)Weak (collisions also found)
Preimage ResistancePoorBetter than MD5 but still broken
CryptanalysisBroken (many published attacks)Broken (Google’s SHAttered attack)

🔥 Real-World Attacks:

  • MD5: Flame malware, rogue certificates, password hashes cracked.

  • SHA-1: SHAttered (2017) - First practical collision found using two PDFs.


✅ 3. Use Cases (Current Status)

Use CaseMD5SHA-1
File Checksums✅ Still used (non-secure)✅ Still used (non-secure)
Digital Signatures❌ Unsafe❌ Unsafe
Certificates❌ Deprecated❌ Deprecated
Password Hashing❌ Not recommended❌ Not recommended

Preferred secure alternatives:

  • Use SHA-256 or SHA-3 for cryptographic use.

  • Use bcrypt, scrypt, or Argon2 for password hashing.


🧪 Example Hashes:

Plaintext: hello

  • MD5: 5d41402abc4b2a76b9719d911017c592

  • SHA-1: aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d


🧠 Summary

FeatureMD5SHA-1
SpeedFasterSlower
Output Size128-bit160-bit
SecurityVery weak (broken)Weak (also broken)
StatusDeprecated for security useDeprecated for security use