What is password hashing?

In short
Password hashing is a way to store passwords so that the original password cannot be read back, even if the stored data leaks. The app keeps only a scrambled version, and checks logins by hashing the typed password and comparing the results.
Why not store passwords as they are
If a database leaks and passwords are stored as plain text, every account is exposed at once. Attackers can log in as any user and try the same password on other sites. Good password storage assumes that the database may one day be stolen, and makes the stolen data as useless as possible.
Password hashing solves this by running each password through a one-way function. A hash function turns input into a fixed-looking string of characters. The result is easy to compute from the password, but it is practically impossible to reverse back into the password. When someone logs in, the application hashes the typed password and compares it with the stored hash. The app never needs to know the original password again.
Hashing is not encryption
Encryption is two-way. Anyone holding the right key can get the original data back. That makes encryption useful for data you must display later, such as an address on a profile. Passwords do not need to be read back, so hashing is the better fit. Even if an attacker gets the hashes, they cannot simply use them to log in.
The documentation notes that encrypting passwords should only happen in rare cases, such as when the app must present the original password to another system that does not support a modern login method. Where possible, the design should avoid storing passwords in a recoverable form at all.
Why fast hashes are a problem
Hashing alone is not enough. Many common hash functions, such as SHA-256, are designed to be fast. That speed helps an attacker. With modern graphics cards and rented cloud servers, an attacker can test huge numbers of guesses cheaply. Common passwords, leaked password lists, and dictionaries make the job even easier.
For passwords, developers should choose slow, memory-hard algorithms. Argon2id, bcrypt, and PBKDF2 are the names most often recommended. Their slowness makes each guess expensive, so large-scale guessing becomes much harder.
Salt and pepper
A salt is a random value generated for each password and mixed into the hash. Because every user has a different salt, two people with the same password get different hashes. An attacker cannot reuse one precomputed table of hashes across the whole database. They must crack each hash separately.
Most widely used libraries create and store salts automatically, so developers rarely need to handle them by hand.
A pepper is an extra secret value shared across passwords. Unlike a salt, it is not stored next to the hash. It is kept in a secrets vault or a hardware security module, so a stolen database alone does not reveal it. The documentation stresses that a pepper adds defense in depth but gives no strong protection on its own. Changing a pepper is hard, because it would require users to reset their passwords.
Work factors and upgrades
The work factor controls how slow the hash is. A higher value makes cracking harder, but it also makes each login slower. If it is set too high, the server can be overloaded by a flood of login attempts. The documentation suggests that a single hash should take less than one second, and that teams should measure the value on their own servers.
Because hardware gets faster, the work factor should be raised over time. A common approach is to re-hash each password with the new setting the next time the user logs in. Users who never return keep their older hashes, so some teams require a reset for those accounts.
Practical starting points
The current guidance suggests Argon2id as the first choice, with a minimum memory setting of 19 MiB, an iteration count of 2, and a parallelism of 1. If Argon2id is not available, scrypt is an option. For legacy systems that use bcrypt, a work factor of 10 or more is advised, and bcrypt only uses the first 72 bytes of a password. When FIPS-140 compliance is required, PBKDF2 with HMAC-SHA-256 and a work factor of 600,000 or more is the suggested path.
Do not invent your own algorithm. Use a well-tested library, and check the official cheat sheet before choosing settings. For background on keeping stored data safe, see the general security guidance on encryption.
FAQ
Can a hashed password be turned back into the original?
No. A good password hash is a one-way function, so the original cannot be calculated from the hash. Attackers can only guess passwords, hash each guess, and compare the results.
Why is SHA-256 not recommended for passwords?
SHA-256 is designed to be fast. That speed lets attackers test very large numbers of guesses. Password hashing should use slow algorithms such as Argon2id, bcrypt, or PBKDF2.
Do I need to create salts myself?
Usually not. Most widely used password hashing libraries generate and manage salts automatically when they are used correctly.
What is the difference between a salt and a pepper?
A salt is unique to each password and is stored with the hash. A pepper is shared across passwords and must be kept secret, outside the database.
Sources
This page is based on the official documentation below. Read it for full detail.
Password hashing — official documentation ↗