How Hashing and Salting Secure Passwords by Preventing Rainbow Table Attacks
By appending a unique string of random characters to every password before it is mathematically scrambled, servers render pre-computed database attacks mathematically infeasible.
By Tiago Sousa
- Security Architects
- Emphasize that salting is a baseline requirement that must be paired with computationally expensive hashing algorithms like bcrypt.
- Compliance Auditors
- Focus on adherence to strict regulatory guidelines, ensuring salts are sufficiently long and randomly generated.
- Historical Threat Actors
- View rainbow tables as a highly efficient, albeit now outdated, method for exploiting deterministic hashing in legacy systems.
Perspectives this story doesn't cover
- End Users
- Legacy System Administrators
At a glance
- Modern systems never store actual passwords, but rather irreversible mathematical hashes of those passwords.
- Basic hashing is deterministic, meaning the same password always produces the same hash.
- Rainbow tables exploit this by pre-computing millions of hashes to instantly crack stolen databases.
- A salt is a unique, random string added to a password before hashing, ensuring identical passwords produce different hashes.
- Salting forces attackers to compute hashes individually, rendering rainbow tables mathematically useless.
- Modern security pairs salting with slow hashing algorithms to further delay brute-force attacks.
The security of a password is not determined when a user types it into a login field, but in the millisecond after it reaches the server, during a step called salting. By appending a unique, random string of characters to the password before mathematically scrambling it, the server ensures that even if two users choose the exact same password, their stored data looks entirely different. This single operation is what prevents attackers from cracking millions of accounts at once using pre-computed databases. Understanding this mechanism reveals why modern authentication systems can safely store credentials without ever actually knowing what they are.[8]
To understand why salting matters, you have to understand how systems store passwords in the first place. Modern databases do not save the actual text of a password. Instead, they use a cryptographic hash function—a one-way mathematical algorithm that converts any input into a fixed-length string of characters, typically 256 bits long. This process is designed to be irreversible, meaning that looking at the resulting hash provides no clues about the original password that generated it. When a user attempts to log in, the system simply hashes the password they just typed and compares it to the hash stored in the database. If the two strings match perfectly, the system grants access, all without ever storing the plaintext credential.[1][5]
According to the National Institute of Standards and Technology (NIST) Special Publication 800-63B, hashing is the foundational requirement for secure credential storage. Their guidelines dictate that systems must never store passwords in a reversible format. However, basic hashing alone has a fatal flaw: it is entirely deterministic. The same input always produces the exact same output. If a user's password is "password123", the resulting hash will always be identical, no matter which system is generating it or when the account was created.[4][7]
This predictability gave rise to the rainbow table attack. A rainbow table is a massive, pre-computed database that maps plaintext passwords to their corresponding hash values. Because hashing algorithms are public and deterministic, an attacker can take a list of 10 billion common passwords, run them all through a standard hashing algorithm, and store the results. When they breach a database and steal a list of hashed passwords, they do not need to guess them one by one.[2][6]
Instead of spending months or years attempting to crack the hashes computationally, the attacker simply looks up the stolen hashes in their pre-computed rainbow table. If a match is found, they instantly know the original password. This method trades computational processing time for storage space, allowing attackers to crack upwards of 100,000 passwords per second simply by cross-referencing a massive file. For legacy systems that rely on basic hashing without additional protections, a stolen database can be fully compromised almost immediately.[3][6]
Instead of spending months or years attempting to crack the hashes computationally, the attacker simply looks up the stolen hashes in their pre-computed rainbow table.
This is exactly where the cryptographic salt comes in to break the attack chain. A salt is a unique, randomly generated string of characters created for each individual user at the exact moment they set up their account or change their password. Before the user's password is run through the hashing algorithm, the server appends this random string to it. The resulting combined string is then hashed, and the final output is stored in the database. Crucially, the salt itself is not a secret; it is stored in plain text right next to the hash in the database, because its purpose is to provide uniqueness, not secrecy.[1][2]
Because the salt is entirely unique to each user, two users who happen to choose the exact same password—like "password123"—will have completely different inputs going into the hash function. Consequently, their final stored hashes will look nothing alike. This simple addition destroys the utility of a rainbow table. An attacker can no longer rely on a pre-computed list of common passwords, because the unique salt changes the resulting hash every single time, rendering the pre-calculated matches useless.[2][5]
To crack a salted hash using a rainbow table, the attacker would have to compute a brand new, massive table for every single user in the database, incorporating that specific user's unique salt into every calculation. The computational time and storage space required to generate millions of custom rainbow tables makes the attack mathematically and financially infeasible. By forcing the attacker to compute hashes on a per-user basis, salting eliminates the economies of scale that make rainbow tables effective.[1][3][6]
While rainbow tables are largely considered obsolete in modern cybersecurity—with industry publications noting their decline as early as 2021 due to the widespread adoption of salting—the underlying principles remain a critical part of system architecture. NIST's updated guidelines emphasize that salts must be at least 32 bits in length and generated using an approved random number generator to ensure they cannot be predicted or repeated. A salt that is too short or predictable could theoretically allow an attacker to pre-compute tables for the most common salt values.[3][4][7]
Furthermore, modern authentication systems pair unique salting with intentionally slow hashing algorithms, such as bcrypt, scrypt, or Argon2. These algorithms are specifically designed to be computationally expensive, adding a deliberate 100-millisecond time delay to each hash calculation. This delay is completely imperceptible to a legitimate user logging in, but it is devastating to an attacker attempting to brute-force a salted hash. By drastically reducing the number of guesses their hardware can make to fewer than 10 per second, these algorithms ensure that guessing passwords one by one will take centuries.[1][5]
The combination of a unique, randomly generated salt and a computationally expensive hashing algorithm forms the bedrock of modern password security. It shifts the mathematical advantage back to the defender, ensuring that even if a database is breached and the hashes are stolen, the credentials within remain locked away. Because the mathematics of hashing are absolute, security documentation across the industry focuses entirely on implementation mechanics rather than individual commentary, with none of the cited technical guidelines relying on direct quotations to establish these standards. This foundational security practice guarantees that a compromised server does not automatically result in compromised user accounts, protecting the broader digital ecosystem from cascading failures.[8]
Terms to know
- Hash function
- A mathematical algorithm that converts an input into a fixed-size string of text, which cannot be reversed to reveal the original input.
- Rainbow table
- A massive, pre-computed database of plaintext passwords and their corresponding hash values, used to rapidly crack unsalted password databases.
- Salt
- A unique, randomly generated string of characters added to a password before it is hashed to ensure the resulting output is always unique.
- Plaintext
- Data, such as a password, in its original, readable form before any encryption or hashing has been applied.
- Deterministic
- A property of an algorithm where providing the exact same input will always produce the exact same output.
Questions readers ask
What is a cryptographic hash?
A one-way mathematical function that converts an input, like a password, into a fixed-length string of characters. It is designed to be irreversible.
Why are rainbow tables dangerous?
They allow attackers to instantly look up the plaintext passwords for stolen hashes by using a massive, pre-computed database, bypassing the need to guess passwords one by one.
Is the salt kept secret?
No, the salt is stored in plain text alongside the hash in the database. Its purpose is to provide uniqueness to the hash calculation, not secrecy.
Can a salted password still be cracked?
Yes, but it requires an attacker to brute-force the password one guess at a time. When paired with a slow hashing algorithm, this process can take centuries.
Sources
[1]WorkOSSecurity ArchitectsRainbow table attacks: What they are and how to prevent them
Read on WorkOS →
[2]Inventive HQHistorical Threat ActorsWhat Are Rainbow Tables and How Do Salts Protect Passwords?
Read on Inventive HQ →
[3]CSO OnlineHistorical Threat ActorsRainbow tables explained: How they work and why they're (mostly) obsolete
Read on CSO Online →
[4]DrataCompliance AuditorsThe Complete Guide to NIST Password Guidelines
Read on Drata →
[5]Geisel SoftwareSecurity ArchitectsPassword Hashing: Protecting Data From Rainbow Table Attacks
Read on Geisel Software →
[6]Beyond IdentitySecurity ArchitectsRainbow Table Attack
Read on Beyond Identity →
[7]StrongDMCompliance AuditorsNIST Password Guidelines: 2026 Updates & Best Practices
Read on StrongDM →
[8]Factlen Editorial TeamSecurity ArchitectsSynthesis by Factlen editorial team
Read on Factlen Editorial Team →
Comments
More in Guides
See all →Network Infrastructure
Anycast Routing and Edge Caching: How a CDN Reduces Latency by Serving Content from the Nearest Node
6 sources
Acoustic Science
The 2 kHz to 5 kHz Peak: How the Fletcher-Munson Curves Dictate the Human Ear's Uneven Sensitivity
5 sources
Corporate Valuation
How Enterprise Value's Inclusion of Net Debt and Minority Interest Determines the True Cost of Acquiring a Company
5 sources
Financial Regulation
The EU's Digital Operational Resilience Act (DORA): A Guide to the New Rules Reshaping Financial Sector ICT and Third-Party Risk
4 sources
Every angle. Every day.
Get Guides stories with full source coverage and perspective breakdowns delivered to your inbox.




