Security

bcrypt vs Argon2: Which Password Hash Should You Use in 2026?

Choose Argon2id or bcrypt for password storage with current OWASP guidance. Compare memory cost, bcrypt's 72-byte limit, and how to tune work factors.

bcryptargon2password-hashingsecuritycryptographyscrypt

bcrypt vs Argon2: Which Password Hash Should You Use in 2026?

Every serious auth tutorial eventually tells you: "Don't use SHA-256 for passwords. Use bcrypt or Argon2." That's correct, but it's also where most tutorials stop. If both are acceptable, which one do you pick? And why?

The short answer: choose Argon2id for a new password store when a well-maintained implementation is available. bcrypt remains useful for existing systems, but it has a 72-byte input limit and less flexibility in memory cost. Benchmark either algorithm on your own infrastructure. OWASP's password storage cheat sheet gives current minimum parameters.

Why Not Just Use SHA-256?

Before comparing the two, it's worth remembering what problem we're solving. A password hash needs to be slow. Fast cryptographic hashes like SHA-256 are designed to be as efficient as possible — the exact opposite of what you want for passwords.

Fast SHA-256 lets an attacker test many guesses after a database leak. How quickly any password falls depends on its randomness, the attacker's hardware, and whether each password had a unique salt. Plain SHA-256 has no tunable cost or memory requirement for password storage.

Password hashing functions like bcrypt and Argon2 deliberately consume CPU time or memory. Their cost can be raised as hardware improves; exact guessing rates depend on configuration and attacker hardware.

You can see the speed difference for yourself: generating a SHA-256 hash with the SHA-256 Generator is instant; generating the same password through the bcrypt Generator takes a perceptible fraction of a second. That delay is the whole point.

What bcrypt Is

bcrypt was introduced at USENIX 1999 by Niels Provos and David Mazières. It's based on the Blowfish cipher, configured to be deliberately expensive to compute.

Its defining characteristic is the cost factor — a small integer (typically 10, 12, or 14) that exponentially controls how much CPU work is required:

  • cost = 10 → 2^10 = 1,024 rounds of the expensive key schedule
  • cost = 12 → 2^12 = 4,096 rounds (4× slower)
  • cost = 14 → 2^14 = 16,384 rounds (16× slower)

A bcrypt hash looks like this:

$2b$12$N9qo8uLOickgx2ZMRZoMyeIjZAgcfl7p92ldGxad68LJZdL17lhWy
 │   │  │                      │
 │   │  │                      └─ hash (31 chars, Base64-like)
 │   │  └─ 22-char Base64-encoded salt (128 bits)
 │   └─ cost factor (12)
 └─ algorithm version (2b)

The salt is embedded in the hash output, so you never need to store it separately. Verification is a single function call that re-derives the hash from the supplied password and compares.

What Argon2 Is

Argon2 won the Password Hashing Competition in 2015 — a multi-year, open contest specifically designed to find a successor to bcrypt and scrypt. It was published as RFC 9106 in 2021.

Argon2 comes in three variants:

  • Argon2d — maximizes resistance to GPU cracking, but is vulnerable to side-channel attacks. Use for cryptocurrencies and offline contexts.
  • Argon2i — resistant to side-channel attacks, weaker against GPU cracking. Use when the hash is computed in an untrusted environment.
  • Argon2id — a hybrid of the two. This is what you want for password hashing. It's the default recommendation in RFC 9106.

Argon2 takes three tunable parameters instead of one:

Parameter Symbol What it controls
Memory m KB of RAM used per hash
Iterations t Number of passes over memory
Parallelism p Number of parallel threads

OWASP currently lists a minimum Argon2id configuration of m = 19456 KiB (19 MiB), t = 2, p = 1. Treat it as a floor, then benchmark and raise the cost if your service can afford it.

An Argon2 hash looks like:

$argon2id$v=19$m=19456,t=2,p=1$c2FsdA$hash...

The Core Difference: Memory-Hardness

The real reason Argon2 exists is memory-hardness.

bcrypt uses a fixed ~4 KB of memory regardless of cost factor. That means a determined attacker can build ASIC or FPGA hardware that parallelizes bcrypt cracking at massive scale — thousands of bcrypt cores on a single chip, each with its own small memory.

Argon2 can be configured to require hundreds of megabytes of memory per hash. An ASIC that parallelizes Argon2 must physically include all that RAM, which drastically increases cost per core. This is called memory-hard and it's the single biggest argument for Argon2 over bcrypt.

In practice, for server-side web authentication, both algorithms force attackers to use commodity hardware (CPUs or GPUs). The gap between bcrypt and Argon2 in real-world attacker economics is smaller than the gap between bcrypt and SHA-256 — which is enormous.

Comparison at a Glance

bcrypt Argon2id
Year 1999 2015
Based on Blowfish BLAKE2b + custom mixing
Memory-hard? No (~4 KB fixed) Yes (configurable)
Tunable parameters 1 (cost) 3 (memory, time, parallelism)
Maximum password length 72 bytes (quietly truncates) Effectively unlimited
Salt Built into hash output Built into hash output
Output length 60 chars (fixed) Variable, configurable
Library support Universal Growing — mainstream in modern languages
Standardization De facto RFC 9106
Best against GPU cracking Good Better
Best against ASIC cracking Weak Strong

The 72-Byte Trap

bcrypt's most famous footgun: it silently truncates passwords at 72 bytes. If a user's password is 80 characters long, the last 8 characters are ignored. Two different long passwords that share the first 72 bytes will produce the same hash.

This is a byte limit, not a character limit: a Unicode password may reach it sooner than 72 characters. Check the library's behavior and set a clear policy. Do not blindly pre-hash with raw SHA-256 bytes before bcrypt. OWASP warns that null bytes and password-shucking attacks can make naive pre-hashing unsafe. If long passwords are important for a new system, Argon2id avoids bcrypt's limit. If an existing bcrypt deployment needs pre-hashing, follow a reviewed, versioned scheme such as OWASP's keyed HMAC approach and plan migration carefully.

Argon2 has no equivalent length limit.

Cost Parameter Selection

Cost parameters matter, but so do memory hardness, library behavior, and deployment limits. Avoid treating one cost value as universally safe.

Benchmark verification on production-like hardware under expected login load. Raise the work factor as far as your latency and capacity budget allows; OWASP notes there is no single ideal time target and generally suggests keeping a hash below one second.

Benchmark on your actual production hardware, not your laptop. As CPUs get faster, revisit every 1–2 years.

bcrypt

import bcrypt, time
for cost in range(10, 16):
    start = time.time()
    bcrypt.hashpw(b"test password", bcrypt.gensalt(cost))
    print(f"cost={cost}: {(time.time() - start) * 1000:.0f}ms")

Choose a cost that meets your measured budget. OWASP lists bcrypt work factor 10 as a minimum for legacy systems; higher settings may be appropriate depending on your hardware.

Argon2id

from argon2 import PasswordHasher
for m in [15360, 19456, 47104]:
    ph = PasswordHasher(memory_cost=m, time_cost=2, parallelism=1)
    # benchmark...

OWASP's baseline of m=19456, t=2, p=1 is a reasonable starting point.

Rehashing on Login

Cost parameters get more aggressive over time. To migrate old hashes to newer parameters without forcing a mass password reset:

  1. User logs in; you verify their password against the stored hash.
  2. If the password is correct and the stored hash uses outdated parameters, re-hash with the new parameters and update the database.
  3. If the password is wrong, do nothing — the attacker can't get the new hash without knowing the password.

Most mature libraries expose a needs_rehash() helper for exactly this pattern. Use it.

What About scrypt?

scrypt was Colin Percival's 2009 answer to bcrypt's lack of memory-hardness. It predates Argon2 and influenced its design.

scrypt remains a supported memory-hard option in OWASP's guidance when Argon2id is unavailable. Its N, r, and p settings also need careful benchmarking.

Which Should You Actually Use?

Use Argon2id if:

  • You're starting a new project with no existing auth.
  • Your stack has a well-maintained Argon2 library.
  • You want to follow current OWASP and IETF guidance.

Use bcrypt if:

  • You already have bcrypt hashes in your database (don't migrate for migration's sake).
  • Your language or framework has poor Argon2 support.
  • You need maximum compatibility (e.g., writing a library others will use).
  • You're integrating with Apache .htpasswd files or similar legacy formats — the htpasswd Generator uses bcrypt for a reason.

Don't use: plain SHA-256, SHA-512, MD5, or any unsalted hash. These are not password hashes. They were never meant to be.

Quick Reference

  • Both bcrypt and Argon2id are acceptable for production password hashing.
  • Argon2id is the modern choice (RFC 9106, memory-hard, winner of the PHC).
  • bcrypt is the pragmatic choice (ubiquitous, battle-tested, 25+ years of production use).
  • Benchmark cost and memory settings on your system; there is no universal 250 ms target.
  • bcrypt implementations commonly limit input to 72 bytes. Check your library and do not use naive raw SHA-256 pre-hashing as a workaround.
  • Always rehash on login when cost parameters are upgraded.
  • Use test passwords in the bcrypt Generator or Argon2 Generator to understand output formats. Validate production behavior with your application's own library and deployment settings.