Password hashing is essential for protecting user credentials online. Learn how hashing, salt, and specialized algorithms like bcrypt and Argon2 prevent attackers from accessing passwords, even in the event of a database breach. This guide also explains why plain text storage is dangerous and outlines best practices for secure password management.
Password hashing is a critical security practice that protects user credentials online. While a password may seem like a simple text string, for a website it represents one of the most sensitive types of data. If a service stores passwords in plain text, any database leak immediately gives attackers ready-made combinations to access accounts. Modern systems therefore use password hashing-a method of storing not the password itself, but its irreversible digital representation.
When registering, a password is processed through a special algorithm that creates a hash. It is this hash that is stored in the database. When the user logs in, the site again calculates the hash of the entered password and compares it with the saved value. If they match, the password is considered correct.
This approach does not make the system absolutely invulnerable, but it significantly reduces the consequences of a data breach. Even if attackers obtain the database, they should not see the original passwords-they must try to crack them from hashes, which, if implemented correctly, can require enormous computing resources.
Password hashing is the process of converting an original password into a fixed-length string using a special hash function. For example, the password PixelBurn2026! becomes a completely different value after processing, making it impossible to simply determine the original text.
A hash function works in one direction: it's easy to get a hash from a password, but it's impossible to reverse the process and restore the password from its hash. This is what distinguishes hashing from encryption. Encrypted data can be decrypted with a key, while for a hash, no such key exists.
An important property is predictability: the same password under the same conditions always gives the same hash. This allows a website to check a password's correctness without storing its original value.
Even a minor change in the input completely changes the result. Passwords like Password123 and Password124 will have entirely different hashes, differing by just one character. The appearance of the resulting hashes reveals nothing about how similar the original passwords were.
However, a hash itself cannot be considered absolutely secure. Attackers do not need to "decrypt" it-they can simply try different passwords, compute their hashes, and compare them to the stolen value. If a match is found, the original password is effectively known. Therefore, security depends not just on hashing itself, but on the algorithm used, the presence of a salt, and computational complexity settings.
When a user creates an account, the website should never save the entered password in plain text. Instead, the server processes it with a hashing algorithm and stores only the result, along with any additional parameters needed for future verification.
On subsequent logins, the user enters their password again. The server applies the same algorithm and compares the new result with the stored hash. If the values match, the system considers the password correct and grants access.
Thus, a properly implemented service never needs to know the original password after registration. It only works with the result of its transformation. This is why a reputable website cannot simply display an old password to a user on request.
If a password is forgotten, secure services typically do not send it back. Instead, they initiate a reset procedure: the user confirms account access and sets a new password, which is then hashed and stored in the database.
This approach is especially important if the database is leaked. If plain text passwords are inside, attackers get direct access. If only properly prepared hashes are stored, attackers must first crack the original passwords-a task whose difficulty depends on the algorithm, salt, and hashing parameters.
If a website stores passwords in plain text, any database leak results in the immediate compromise of user accounts. Attackers do not need to guess or decrypt anything-they instantly receive pairs of logins, email addresses, and valid passwords.
This problem is made worse by password reuse. Users often use the same combination for forums, email, online stores, and other services. Thus, a single site's leak allows an attacker to try those credentials elsewhere, potentially gaining access to multiple accounts.
Learn more about what to do after such incidents in the guide How to Check if Your Data Has Been Leaked Online and Protect Your Passwords in 2025.
Even basic hashing is insufficient if the algorithm used is too fast. For example, SHA-256 is great for data integrity checks but not designed for secure password storage. Modern GPUs can compute huge numbers of such hashes quickly, making it possible to brute-force simple and popular passwords.
Attackers typically do not attempt to mathematically reverse a hash function. Instead, they use dictionaries of common passwords, combinations of words, dates, and symbols, compute the hash for each, and compare it to the stolen database. The faster the algorithm, the more possibilities can be checked per second.
Secure password storage relies on several layers. In addition to hashing, a unique salt and special algorithms are used, which intentionally require significant computational resources. This makes mass brute-forcing much slower and more expensive.
Even the best hashing algorithm is weakened if identical passwords always become identical hashes. If two users select the same password, without extra measures their hashes will match. This simplifies mass analysis of a stolen database and helps attackers quickly find popular combinations.
The solution is a salt-a random value added to the password before hashing. A unique salt is generated for each user, so even identical passwords produce different hashes.
For instance, two users may choose the password qwerty123. If each has a different salt, the final hashes will be completely different. Attackers can no longer compute the hash of a common password once and instantly find all users with that combination.
Salt is especially effective against precomputed hash tables, known as rainbow tables. Without salt, attackers can precompute hashes for millions of common passwords and quickly search for matches in a stolen database. Unique salts force attackers to brute-force each user individually.
Salt does not need to be secret. It is usually stored in the database alongside the password hash, as the server requires it for verification. Its job is to make every hash unique, not to remain hidden.
However, salt alone does not protect a weak password from brute-force attacks. If a user chooses a simple combination, attackers can still try to guess it. Therefore, salt should be used together with a specialized hashing algorithm that makes each attempt computationally expensive.
Not just any cryptographic hash function is suitable for passwords. Algorithms like SHA-256 or SHA-512 are intentionally fast, which is useful for file verification and digital signatures, but is a disadvantage for password protection. The faster a hash is computed, the more attempts an attacker can make per second.
For password hashing, specialized algorithms are used to deliberately make computation more demanding. One of the most well-known is bcrypt, which allows you to set the computational cost-the higher the cost parameter, the longer it takes to compute a hash. The server barely notices this delay during normal logins, but mass brute-forcing millions of options becomes much slower.
A more modern approach is provided by Argon2. It can limit attackers not only by computation time, but also by the amount of required memory. This is especially important against GPU and specialized hardware attacks, which efficiently perform huge numbers of simple operations in parallel. The Argon2id variant is commonly used for password storage, combining different Argon2 protection modes.
When comparing bcrypt vs Argon2, it's not that bcrypt has suddenly become obsolete. It has been used for decades and, with proper settings, remains a strong safeguard. However, new projects often prefer Argon2id for its flexible configuration of computational and memory requirements.
Security also depends on algorithm parameters. If the difficulty is set too low, even a modern function will be computed too quickly. Parameters are periodically updated as hardware performance improves, maintaining a balance between user convenience and the cost of mass brute-forcing for attackers.
The industry is also advancing towards login methods where users never transmit a traditional password to the server at all. Learn more in our article Passwordless Security Systems: What Are Passkeys, FIDO2, and WebAuthn?.
Password hashing enables websites to verify user credentials without ever storing the password itself. Instead of the original password, the database keeps a hash, and at login, the server recalculates the hash for the entered value and compares the results.
A robust storage scheme goes beyond just a hash function. A unique salt protects identical passwords from producing identical hashes, and specialized algorithms like bcrypt and Argon2id make mass brute-forcing significantly more time- and resource-intensive.
If a service stores passwords as plain text or uses a fast algorithm without a salt, a single database leak can put thousands of accounts at risk. That's why modern systems follow a simple principle: a user's password should never be stored in a form that can be directly read or recovered.