Skip to content
IT glossary
SecurityUpdated December 3, 2026

Password hashing

Хеширование паролей

A service can check your password without storing the password itself. It stores a hash instead and uses an algorithm that makes each password guess costly to check if the database is stolen.

Also known as: bcrypt, соль

What password hashing protects

A login system needs to tell whether a password is correct. It does not need to read that password back from its database. At sign-up it stores a password hash; at sign-in it uses the stored record to verify the submitted password. There is no decryption step. If someone forgets their password, the service resets it rather than recovering it.

Salt and cost solve different problems

A salt is a fresh random value generated for each password hash. The hashing library uses it as an input and saves it with the result. Two accounts that use the same password get different hashes because their salts differ. That prevents someone with a copy of the database from spotting shared passwords by comparing hashes or checking one precomputed result against every account. A salt is not a secret and does not stop guesses against an individual record.

The algorithm's cost settings determine how much work a guess takes. Argon2id is a common first choice for new systems because you can tune both computation and memory use. You will also see bcrypt in existing systems, where a cost setting controls the amount of computation. Benchmark settings on the hardware that handles logins and under realistic concurrency: each check should be expensive enough to slow guessing without exhausting the resources the service needs to handle sign-ins.

What goes into a database record?

signup: stored = password_hash(password)
login:  matched = password_verify(stored, submitted_password)

These names stand for library operations. The first generates a salt and typically returns an encoded string with the algorithm identifier, cost settings, salt, and hash. The second reads that string and uses the original salt and settings to check the submission. If a successful login reveals that the record uses outdated settings, the application can hash the submitted password again with a fresh salt and replace the record.

Common mistakes and interview follow-ups

Don't substitute plain SHA-256, even with a salt: a general-purpose hash is designed to run quickly. Don't use reversible encryption as a substitute either; whoever obtains the key can recover the passwords. If you maintain a bcrypt-based system, check how the library handles the algorithm's 72-byte input limit. Bytes aren't characters, and some implementations reject longer inputs while others truncate them.

A typical interview follow-up is: “Why bother tuning the hash if logins are rate-limited?” Rate limits constrain requests to your service. After a database leak, someone can check guesses against their own copy without making a single login request. Password hashing is what raises the cost of those offline checks.