Hashing: How Computers Check a Secret Without Saving It
How can a website check your password without keeping it in a readable list? Hashing helps: it runs data through a mathematical procedure to produce a value that can be checked again later.
The procedure is called a hash function, and its result is a hash value or digest. Security systems use cryptographic hash functions, designed to make it difficult to work backward from a result or deliberately find different inputs with the same result.
Hashing isn't encryption with the key thrown away. Encryption is designed to be reversed with the right key; a hash doesn't contain a recoverable copy of the original data.
How Can a Website Check a Password It Does Not Store?
Follow a password through the process
A well-designed service uses a password-hashing method that makes guessing expensive, rather than simply saving your password or applying a fast file-checking algorithm.
Here's a simplified version of registration and a later login:
- Create the record. The service combines your password with a unique random value called a salt and processes them using its password-hashing method.
- Store what verification needs. It keeps the resulting hash, the salt, and information about the method and its cost settings, which control how much computing work each attempt requires.
- Check a later attempt. When you log in, the service uses the stored salt and settings to process the password you just entered.
- Compare the results. A match passes the password check; the service may still require another authentication step, such as a security key you plug in or tap.
The National Institute of Standards and Technology's password guidance calls for salted hashing with a suitable cost and for storing the information needed to repeat the check. The service doesn't need to keep a readable password as its stored reference.
Notice that a fresh random salt isn't substituted during each comparison. The check uses the salt associated with that stored password record.
Why a stolen hash still matters
An attacker doesn't have to reverse a hash to test a likely password. They can process a guess using the stolen record's salt and settings, then compare the result.
That's an offline attack: the guessing happens on the attacker's computers, outside the website's login controls. A limit on failed website logins won't slow those local calculations.
OWASP, a software-security nonprofit, recommends purpose-built password-hashing methods such as Argon2id with appropriate settings. Salts stop attackers from reusing one calculation across every account; costly processing makes each separate guess more expensive.
Neither measure turns an easily guessed password into an unknowable secret.
- Stop typing passwords: the key enters them for you.
- Add a second factor to your accounts with the same device.
- Relax if you lose it: it is PIN-protected and built to resist tampering.
Files call for a different kind of speed
For a large download, quick hashing is useful. SHA-256 is a cryptographic hash function that produces a digest of 256 bits, or ones and zeros, to compare with the publisher's expected value.
Exactly the same bytes, the units making up the file, produce the same digest under the same function. Different inputs can theoretically collide, meaning they share a result, but secure cryptographic functions are designed to make finding such pairs impractical.
The expected value must come from a trusted source. Ubuntu's verification instructions use a digital signature, a key-based check of who signed the reference list, before comparing the download with that list.
What about blockchains?
A blockchain is a sequence of records grouped into linked blocks. In Bitcoin, each block includes a hash of the previous block's header, its identifying and control information, so changing earlier data breaks the existing links.
But calculating replacement hashes isn't, by itself, impossibly hard. Bitcoin's design also relies on validation rules and proof of work, a process requiring repeated calculations to find an acceptable block hash.
The linked hashes help expose changes; the surrounding rules determine which history the network accepts. Hashing supplies a useful check, while the system using it must decide what that check means.
Shadow Password Files Keep the Check Separate

Work Factor: Making Each Password Guess Cost More

What Is Salting in Password Security and How Does It Work?

QUOTE:
"Amateurs hack systems, professionals hack people."
