When you save a password on a serious service, the platform does not store the password. It stores a fingerprint of it: a hash. That difference—between storing a secret and storing only the proof that you know it—is what underpins the modern security of every account.
What a hash is and why it is not enough
A hash is what you get when you run a text through a hash function: a deterministic, one-way math operation. Deterministic means the same input always yields the same output; one-way means that starting from the output, reconstructing the input is infeasible. SHA-256, for instance, always returns 64 hexadecimal characters for any message, however long it is.
Changing a single bit of the input changes the output completely. That property is called the avalanche effect, and it is why two similar passwords produce hashes that look nothing alike.
But a bare hash has a serious flaw: attackers do not need to invert it. They can precompute the hashes of millions of common passwords and store them in a list. If your hash matches one on the list, your password is revealed with no effort at all. That precomputed list is called a rainbow table.
Salt: the ingredient against rainbow tables
The classic fix is the salt: a unique random string per user, generated at account creation. The hash is not computed over your bare password, but over password + salt.
With a salt, two users with the same password get different hashes, so a precomputed table is almost useless: an attacker would have to restart from zero for each distinct salt. The salt is not secret—it can sit right next to the hash in the database. Its job is not to hide, but to force recomputation.
Functions designed for passwords
Computing a SHA-256 hash is the work of milliseconds. On a normal server that fits, but on a GPU—a graphics card able to run billions of parallel operations—you get billions of attempts per second. A hash meant for signatures or integrity is a poor guardian of passwords: it is too fast.
That is why dedicated algorithms exist, each with a work factor you can raise as hardware improves:
- bcrypt: based on the Blowfish cipher. Its cost is expressed as a power of two; a cost of 12 means 4,096 internal rounds and makes each attempt slow enough to annoy brute force.
- PBKDF2: repeats a hash thousands of times (e.g. 600,000 rounds of SHA-256 per the OWASP guidance). Simple, but still GPU-friendly because it demands little memory.
- scrypt: adds a memory requirement. It makes the computation need a large amount of RAM, not just CPU, driving up the cost of parallel attacks.
- Argon2: winner of the 2015 Password Hashing Competition and OWASP’s current recommendation. The Argon2id variant resists both memory-hard and GPU attacks, and lets you tune time, memory and parallelism independently.
The key trait of memory-hard functions such as Argon2 or scrypt is that they blunt exactly the attacker’s favourite tool: the massive parallelism of graphics cards.
Pepper, constant-time comparison and managers
On top of the salt, some systems add a pepper: a global secret that lives outside the database, in the server configuration. If the database is stolen but the code is not, the hashes remain unusable without the pepper.
There is another low-level detail that matters: when checking whether the hash matches, the comparison must run in constant time. If the system stops comparing as soon as the first differing character appears, an attacker who times the responses can recover the correct hash character by character. That is why all bytes are always compared, even when they are known not to match—a defence against the timing attack.
And one closing thought: none of these countermeasures matter if the password is weak. Entropy—the amount of uncertainty a secret holds—is measured in bits, and a short, predictable password has very little of it. That is why modern guidance favours long passphrases or password managers that generate and store high-entropy random keys. The hash protects the copy on the server from a passive database theft; the password itself is the first line of defense.
In short: a password manager, a salted and expensive algorithm, and a database that never rushes a comparison. That is how you keep a secret in 2026.





