Hash Collision occurs when two different inputs produce the same hash output. While collisions are theoretically inevitable (infinite inputs, finite outputs), cryptographic hash functions are designed to make finding collisions computationally infeasible.
// For n-bit hash, collision expected after ~2^(n/2) attempts
MD5 (128-bit): ~2^64 operations (broken, practical)
SHA-1 (160-bit): ~2^80 operations (broken, demonstrated)
SHA-256 (256-bit): ~2^128 operations (secure)
// If two documents have same hash:
hash(legitimate.pdf) == hash(malicious.pdf)
// Digital signature on legitimate.pdf
// Also validates malicious.pdf!
// Certificate collision:
// Attacker gets CA to sign benign cert
// Creates malicious cert with same hash