Rainbow Table is a precomputed lookup table for reversing cryptographic hash functions, used for cracking password hashes. It represents a time-memory trade-off: large storage enables fast lookups instead of computing hashes on demand.
// Precomputation phase (done once):
for password in wordlist:
hash = MD5(password)
table[hash] = password
// Attack phase (instant lookup):
stolen_hash = "5f4dcc3b5aa765d61d8327deb882cf99"
password = table[stolen_hash] // Returns "password"
True rainbow tables use chains with reduction functions to compress storage:
// Chain: password → hash → reduce → password2 → hash2 → ...
// Store only: (first_password, final_hash)
// Lookup: compute chains until match found
// Without salt:
hash("password") → same hash for all users
// With salt (unique per user):
hash("password" + "randomsalt123") → unique hash
hash("password" + "differentsalt456") → different hash
// Rainbow table would need entry for every salt combination
// Effectively defeats precomputation