Hashing Fundamentals
When you sign in, a responsible service shouldn’t need to keep a readable copy of your password. Instead, it can store a carefully designed representation called a password hash—and compare that with a fresh calculation when you return.
That small distinction matters. If a database is exposed, storing passwords in plain text can put users at immediate risk. Hashing helps limit the damage, though it isn’t magic: the algorithm, its settings, and the way a system handles passwords all count. Here’s how the process works, in plain language.
A hash function takes input data and produces an output called a hash, hash value, or digest. For password storage, the input is the password, processed by a password-hashing algorithm.
A useful starting point is that hashing is designed to work in one direction. A system can calculate a hash from a password, but it should not be able to simply reverse that hash and recover the original password. When a user signs in, the service processes the password they enter and checks the result against the stored record.
For a broader introduction to the idea, visit Hashing Basics or explore how hash functions work.
Imagine setting up an account on a new service. You choose a password and submit it over a protected connection. The service then uses a password-hashing algorithm to create a stored record. That record commonly includes more than the final hash: it also needs information such as the algorithm and its settings so the service can verify future sign-ins.
The password itself should not be saved as ordinary readable text. If an attacker later obtains a database of password records, they cannot simply open a file and see everyone’s passwords. They may still attempt to guess passwords, which is why the choice of hashing method is crucial.
This is different from encryption. Encryption is designed to be reversible by someone with the right key; hashing is not meant to provide a way to retrieve the original input. Learn more about the distinction in Checksums and Hashes.
When you sign in, the service takes the password you entered and runs it through the relevant password-hashing process. It then checks whether the newly calculated result matches the stored record. If they match, the password is accepted; if they do not, the service should not grant access.
The service doesn’t need to reveal or retrieve the original password to make that comparison. That’s the central idea: verify a password without keeping a readable copy on hand.
Real systems also need to handle practical details, including account recovery, changes to hashing settings, and the safe handling of password input. A secure design is a whole process—not just one function in isolation.
Many familiar cryptographic hash functions are built to calculate quickly. That speed is useful for tasks such as checking data integrity, but it creates a problem for password storage: if an attacker gets a password database, speed can help them test a large number of guesses.
Password-hashing algorithms are designed for a different job. They deliberately make each guess more resource-intensive, slowing down attempts to test many possible passwords. Many also let system operators adjust the work required as computers become more capable. The goal isn’t to make guessing impossible; it’s to make large-scale guessing more costly.
That’s why applying a fast hash function once is not considered an adequate password-storage strategy. For an overview of purpose-built options and their adjustable costs, see Password-Hashing Algorithms.
A general-purpose hash is often designed to do its work quickly. A password-hashing algorithm is designed to make repeated password guesses more expensive. Similar-sounding tools, different jobs.
Password-hashing systems commonly use a salt: a unique, usually random value associated with each password record. The salt is combined with the password as part of the hashing process. It does not need to be secret, and it is typically stored alongside the record.
Salts help ensure that two people who choose the same password do not automatically end up with identical stored results. They also make precomputed lookup tables less useful, because an attacker cannot rely on one precomputed result for every account.
A salt does not make a weak password strong, and it does not replace a suitable password-hashing algorithm. It is one layer in a careful design. Read more in Salts and Password Storage.
Passwords have long served as a simple way to distinguish one authorized user from another. As computer systems began storing more accounts and more personal information, the question became not only “Does this password work?” but also “What happens if the stored account records are exposed?”
Password hashing grew into a practical answer to that second question. It reflects a broader shift in security thinking: systems should be designed with the possibility of mistakes and breaches in mind, rather than assuming data will always remain private. The details have evolved as computers have become faster and attackers have gained more computing power, which is one reason password-hashing settings need periodic review.
For everyday users, the takeaway is straightforward: a service should not need to know your password in readable form. For developers and curious readers, the deeper lesson is that protecting password records requires purpose-built algorithms, salts, sensible cost settings, and ongoing maintenance.
Password hashing can reduce the harm of a database exposure by preventing passwords from being stored in immediately readable form. A well-chosen, properly configured method can also make large-scale guessing slower and more expensive.
But hashing cannot guarantee that an account is safe. Attackers may still guess common or reused passwords, exploit weaknesses elsewhere, or target users with phishing. A password record can also be mishandled if the algorithm or its settings are outdated or implemented incorrectly.
That’s why password storage belongs alongside other security measures—not in place of them. If you’re learning about related online risks, our guide to spotting phishing scams covers ways to recognize suspicious messages and links.
These habits complement secure password storage. They don’t depend on knowing which algorithm a particular service uses, and they help reduce the risk from common account attacks.
Hashing is one piece of a larger data-integrity picture. Continue with these guides: