Hashing Fundamentals

Password-Hashing Algorithms

When you create an account, a responsible service shouldn’t keep a readable copy of your password tucked away for later. Instead, it uses a purpose-built password-hashing algorithm designed to make guessing costly. Here’s how these algorithms work, why their settings matter, and what to know about the names you may encounter.

This guide is educational, not a recommendation to configure authentication systems without expert review. Secure password storage depends on current algorithms, careful implementation, and regular maintenance.

Why password hashing needs its own approach

A password is a secret people often reuse, which makes it especially valuable to attackers. If a service stores passwords in plain text and its database is exposed, those passwords may be immediately readable. Hashing offers a safer alternative: the service stores a derived value and later checks a submitted password against it.

But not all hashing is built for passwords. Many general-purpose cryptographic hash functions are designed to process data quickly. That speed is useful when checking a file or building other security tools—but it also lets an attacker test enormous numbers of password guesses quickly if they steal a password database.

Password-hashing algorithms deliberately make each guess more demanding. They can also use adjustable settings, so a system can raise the work required as ordinary computers become faster. The aim isn’t to make a legitimate login painfully slow; it’s to make mass guessing expensive.

For the underlying concepts, see How Password Hashing Works and Hashing Basics.

What “slow” really means

A slow password hash isn’t simply a poorly performing program. It is a deliberate security trade-off: the system spends a controlled amount of time and, for some algorithms, memory each time it processes a password.

That cost is applied to password verification as well as to an attacker’s guesses. A service therefore needs to choose settings that are demanding enough to hinder large-scale guessing while still allowing ordinary users to sign in reliably. The right balance depends on the application, its hardware, and current guidance—not a single magic number that stays suitable forever.

These settings are often called cost parameters. Depending on the algorithm, they may control the number of iterations, the amount of memory used, or a combination of factors. Over time, systems should review and update their choices. Many implementations can also rehash a password with newer settings after a successful login.

A unique salt is another essential part of password storage. The salt is stored alongside the resulting hash; it is not a secret. By making each stored result distinct, salts prevent identical passwords from producing identical stored values and reduce the usefulness of precomputed lookup tables.

Common password-hashing algorithms

Several established algorithms appear in password-storage discussions. They differ in design and history, and their names alone don’t guarantee a secure setup. Appropriate parameters, reliable libraries, and careful handling all matter.

Argon2

Argon2 was selected as the winner of the Password Hashing Competition, an international effort to identify a modern password-hashing design. It offers configurable memory, time, and parallelism costs. Argon2id is a commonly recommended variant because its design combines protections associated with other Argon2 variants. Implementations still need carefully selected parameters and current, trusted software.

scrypt

Scrypt was designed to make large-scale guessing costly in memory as well as computation. Its adjustable settings let implementations tune the resources required. As with any password-hashing algorithm, a responsible deployment depends on selecting suitable parameters and using a maintained implementation.

bcrypt

Bcrypt has been widely used for password storage for decades and includes an adjustable work factor. Its long history means it may appear in existing systems, but implementations should account for its input-length behavior and follow current library guidance. A familiar name is not a substitute for reviewing configuration and migration plans.

PBKDF2

PBKDF2 repeatedly applies a pseudorandom function to derive a result from a password and salt. It has long-standing standards and broad support, which can make it relevant in environments with specific compatibility or compliance needs. Its security depends on using an appropriate iteration count, a suitable underlying function, and current implementation guidance.

A short history of a moving target

Password storage has evolved alongside computing. A technique that demanded meaningful effort on older hardware may become much easier to repeat as processors improve and attackers gain access to more computing resources. Security recommendations therefore change—not because yesterday’s systems were necessarily careless, but because the cost of computation changes.

That history is one reason modern password-hashing algorithms offer adjustable costs. A system can begin with settings suited to its environment, then revisit them as hardware and guidance evolve. It is also why teams should plan for migration rather than assume that one algorithm choice will remain ideal indefinitely.

Think of it as maintaining a lock: choosing a solid design matters, but so does checking it as the tools used to test locks change. A sound password-storage system is a practice, not a one-time purchase.

What algorithm names don’t tell you

Seeing “Argon2,” “bcrypt,” or “PBKDF2” in documentation does not, by itself, tell you whether a system is secure. The result also depends on the selected cost parameters, salt handling, the quality of the software library, and how the application manages passwords during registration, login, and recovery.

  • Parameters need context. A setting suitable for one server may be too costly—or too weak—for another. Test performance under realistic conditions and consult current security guidance.
  • Use maintained libraries. Established libraries help avoid subtle implementation errors. Avoid inventing a custom password-hashing scheme.
  • Plan for change. Systems should be able to review parameters and, where appropriate, update stored hashes as users authenticate.
  • Protect passwords in transit and in use. Hashing a stored password does not replace secure connections, access controls, or careful application design.

Password hashing also does not guarantee that a user’s password is strong or unique. It reduces the damage a stolen database can cause, but people should still use unique passwords and consider a password manager. For a related topic, explore SHA-2 and SHA-3 Explained to see how cryptographic hash families differ from algorithms purpose-built for password storage.

A practical takeaway

Purpose-built password-hashing algorithms are designed to make each guess more expensive, giving systems a stronger way to store passwords than plain text or a fast, general-purpose hash alone. Their adjustable costs help keep that protection useful as computing changes—but only when the algorithm is implemented carefully and its settings are maintained.

For everyday readers, the key point is simple: a service should not be able to tell you your existing password. If you’re responsible for a system, treat algorithm selection and configuration as an ongoing security decision, and consult current standards and qualified security guidance rather than relying on a one-size-fits-all recipe.

Continue exploring

Build out the password-storage picture with these related guides:

Theme