A rainbow table is a precomputed reverse-lookup structure for likely password inputs. It does not reverse a hash function; it repeatedly hashes candidate passwords and retains enough information to later recover a candidate that produces a target digest. It trades expensive upfront computation for fast lookup against leaked, unsalted password hashes. section 6.4.2 section 6.0
A plain dictionary attack stores every candidate password beside its digest, making a matching digest nearly instantaneous to look up but requiring substantial storage. Rainbow tables compress this dictionary: a hash chain alternates hashing with a reduction function that maps a digest back into a password-shaped candidate. Rather than retain every chain entry, the table stores a chain start keyed by its final digest. section 6.4.2 section 6.4.2
Figure 6.8 Hash digests are the keys. Passwords that resulted in those digests are stored as values.
A full dictionary stores digests as keys and the passwords that produced them as values; rainbow tables reduce that storage burden by retaining chain endpoints instead. section 6.4.2
Chains can merge when different paths reach the same value, reducing coverage. Rainbow tables address this by varying the reduction function by column, so the same digest is reduced differently at different chain positions. This improves resistance to chain collisions, but no reduction function can eliminate the limits of a finite candidate password space. section 6.4.2 section 6.4.2
SHA-256 password demo
A Go implementation restricts passwords to six characters from a 52-letter alphabet, hashes them with SHA-256, and builds chains of length 1,000. A test generates or loads millions of stored chain endpoints, registers 100 users with random passwords, then attempts to recover passwords from their stored hashes and authenticate each recovered result. section 6.4.2 section 6.4.2 section 6.4.2
The attack depends on attacker-controlled precomputation over a predictable candidate space and reusable hash outputs. Long, complex passwords enlarge that space. Salts add stored plaintext values that make hash output less predictable, preventing a single precomputed table from serving all stored password hashes in the same way. section 6.4.2 section 6.4.2
