One-Way Encryption: Checking a Password Without Keeping It
A website doesn't have to keep your password in a form it can read back to you. It can store a calculated result and use it to check what you type next time. This is usually what people mean by “one-way encryption,” although the more accurate name is hashing.
A cryptographic hash function turns input data into a fixed-size result. It is designed to make finding a matching input from the result difficult. There is no normal decryption step that retrieves the original input.
Password storage builds on that comparison idea with methods designed specifically for passwords. The goal is to check a later submission while reducing what a thief can learn from the saved records.
How Can a Website Check a Password It Does Not Store?
Keep the result needed for the next check
Suppose someone creates a password for an account. A suitable storage scheme combines it with a salt, a value chosen for that password, and performs the password-hashing calculation.
The service stores the resulting password hash, along with the salt and the relevant settings. It doesn't need to store a readable copy of the password for this job.
At the next login, the person supplies a candidate password. The service repeats the calculation using that candidate, the saved salt and the same scheme settings. It compares the new result with the stored hash.
The salt isn't a decryption key. It can be stored with the hash and doesn't need to be secret. Its purpose becomes clearer when someone steals the records.
A thief can run the comparison, too
Suppose an attacker obtains the password hashes, salts and settings from a database. They can choose a possible password, perform the same calculation and compare the result with the stolen hash.
This is offline guessing. The attacker works against a copy of the data instead of sending every guess to the website's sign-in page.
A match can reveal a useful password guess without reversing the hash calculation. A familiar or reused password may therefore be found even if the underlying cryptographic method is mathematically sound.
- 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.
Give each password its own work
Salt makes it harder to reuse guessing work across accounts. With a separate salt for each password, an attacker can't simply calculate a single result for a common password and compare that one result with every account.
They can still try that password against an individual account using its salt. That is why password-storage schemes also make each calculation deliberately costly.
A cost setting controls how much work the method requires. Raising the cost makes the service's check more expensive, but it also makes each corresponding guess more expensive for the attacker. The National Institute of Standards and Technology's password-storage guidance describes using a password, salt and cost factor in the storage scheme.
The software-security organization OWASP recommends password-specific methods and identifies Argon2id as one option in its password-storage guidance. It warns against using a fast general-purpose hash such as SHA-256 on its own for this task. A calculation designed to run quickly can also help a thief test guesses quickly.
When the application needs the original
Hashing is useful for the matching question a login service needs to answer. Some other information has to be recovered in its original form.
For example, an application storing a protected delivery address may later need to display that address. A hash won't reconstruct it. Encryption instead turns the data into protected ciphertext, with a corresponding decryption process that recovers the original information using the appropriate key.
Hash Functions: Small Outputs With a Big Job

Password Cracking: How Guesses Work Against a Stolen Database

Work Factor: Making Each Password Guess Cost More

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