Security

bcrypt vs Argon2: Which Password Hash to Use (With Settings)

For new systems, use Argon2id: OWASP's Password Storage Cheat Sheet recommends it first, with at least 19 MiB of memory, 2 iterations and 1 degree of parallelism. bcrypt is still acceptable at a work factor of 10 or more, but OWASP now recommends it only for legacy systems where Argon2id and scrypt aren't available.

bcrypt vs Argon2 at a glance

bcryptArgon2id
SpecificationProvos and Mazières, USENIX 1999 paper; no RFCRFC 9106 (Informational, September 2021)
Cost settingsOne: work factor (log2 of iterations)Three: memory (m), passes (t), lanes (p)
Memory useSmall and fixedWhatever you set, from a few MiB to GiB
Password length limit72 bytesNone in practice
OWASP status (as of October 2026)Legacy systems only, work factor ≥ 10First choice
Hash string$2b$12$<salt><hash>$argon2id$v=19$m=…,t=…,p=…$<salt>$<hash>

Why memory hardness is the real difference

Both algorithms are deliberately slow, so that each guess costs an attacker who has stolen your database real work. The difference is what makes them slow. bcrypt burns CPU time on a small state of fixed size. An attacker with a GPU or custom hardware can run thousands of those small computations side by side, because each one needs so little memory.

Argon2 makes each guess fill and read a block of memory whose size you choose. RFC 9106 calls it a memory-hard function. At 64 MiB per guess, running 1,000 guesses in parallel needs 64 GiB of fast memory, and memory is much more expensive to scale than arithmetic. That is the property OWASP is paying for when it ranks Argon2id above bcrypt.

Neither hash rescues a weak password. A password from the top of a breach list falls in a handful of guesses whatever the hash. The math for that is in how long it takes to crack a password.

Recommended Argon2id settings

Two sources give numbers, and they target different situations. OWASP's minimums for a login server, which it says give equal protection and trade memory for CPU:

Memory (m)Iterations (t)Parallelism (p)
47104 KiB (46 MiB)11
19456 KiB (19 MiB)21
12288 KiB (12 MiB)31
9216 KiB (9 MiB)41
7168 KiB (7 MiB)51

RFC 9106, section 4, gives two recommended profiles: the first is t=1, p=4, m=2 GiB, and the second, for memory-constrained environments, is t=3, p=4, m=64 MiB. Both use a 128-bit salt and a 256-bit tag. The 2 GiB profile is too heavy for most web servers handling concurrent logins, which is why OWASP's floor is far lower. Memory is the expensive setting on your side too: if 50 users log in at the same moment with m=64 MiB, the hashing alone needs about 3.2 GiB.

Recommended bcrypt settings, and the 72-byte limit

OWASP's bcrypt guidance has two parts: a work factor of at least 10, and a maximum password length of 72 bytes. The limit comes from the algorithm. Classic implementations silently ignored everything after byte 72, so two long passwords sharing their first 72 bytes produced the same hash. The limit is in bytes, not characters, and many non-Latin characters take 2 to 4 bytes in UTF-8.

Libraries are starting to refuse instead of truncating. The Python bcrypt package's 5.0.0 changelog says that passing hashpw a password longer than 72 bytes "now raises a ValueError", where it used to truncate. Running it with bcrypt 5.0.0 on Python 3.12 gives:

ValueError: password cannot be longer than 72 bytes, truncate manually if necessary (e.g. my_password[:72])

So an upgrade can turn a silent truncation into a crash on your signup page. Enforce the 72-byte cap in your validation before calling bcrypt. OWASP warns against the common workaround of SHA-256 pre-hashing the password unless you understand the risks: raw hash output can contain null bytes, which the original bcrypt treats as the end of the string, and pre-hashed values open the door to an attack called password shucking.

Measured timings

We ran both in Python 3.12 on a Windows desktop in October 2026, with bcrypt 5.0.0 and argon2-cffi 25.1.0, timing a single hash of the same password:

SettingTime per hash
bcrypt, work factor 1053 ms
bcrypt, work factor 12215 ms
Argon2id, m=19456, t=2, p=1 (OWASP minimum)22 ms
Argon2id, m=65536, t=3, p=4 (argon2-cffi default)58 ms

These are single runs on one machine, so treat them as an order of magnitude and measure on your own server. Two things show up clearly. Each step up in bcrypt work factor doubles the time (10 to 12 is four times slower). And Argon2id is not "slower than bcrypt" by default; its cost is mostly memory, which hurts attackers more than it hurts you.

How to use Argon2id in Python

argon2-cffi's PasswordHasher uses the RFC 9106 low-memory profile by default (t=3, m=65536 KiB, p=4, 16-byte salt, 32-byte hash):

from argon2 import PasswordHasher
from argon2.exceptions import VerifyMismatchError

ph = PasswordHasher()
stored = ph.hash("correct horse battery staple")

try:
    ph.verify(stored, password_from_login_form)
except VerifyMismatchError:
    ...  # reject the login

Example output of ph.hash():

$argon2id$v=19$m=65536,t=3,p=4$B01FhRRtxOvYJScnU5ApOw$pwMRFXhUxfRE3hfnQAxKxDKqPlO240UJCbJ2iyJMmsY

Everything needed to verify, including the salt and parameters, is in that string. A wrong password raises VerifyMismatchError: The password does not match the supplied hash.

How to migrate from bcrypt to Argon2id

You can't convert a bcrypt hash to Argon2, because you don't have the passwords. Upgrade users as they log in instead:

  1. At login, look at the stored string's prefix. $2a$, $2b$ or $2y$ means bcrypt; $argon2id$ means Argon2id.
  2. Verify with the matching algorithm.
  3. If verification succeeds and the hash is bcrypt, hash the password you just received with Argon2id and overwrite the stored value.

The same pattern handles parameter changes later. The argon2-cffi documentation recommends calling ph.check_needs_rehash(stored) after each successful login, because that is the only time you have the plaintext password; it returns True when the stored hash used different parameters from the current hasher. Users who never log in keep their bcrypt hashes, which is fine, since bcrypt at work factor 10 or more is still acceptable.

What about scrypt and PBKDF2?

OWASP puts scrypt second, for when Argon2id isn't available, with a minimum of N=2^17 (128 MiB), r=8, p=1. PBKDF2 is the option when you need FIPS-140 compliance, at 600,000 iterations for PBKDF2-HMAC-SHA256. A plain SHA-256 of the password is not a password hash at all; see hashing vs encryption for why fast hashes are the wrong tool here. Slow hashing also only matters after a breach. Stopping guesses against your live login form is a separate job, covered in how to prevent brute force attacks.

Frequently asked questions

Is bcrypt still secure in 2026?
Yes, with a work factor of at least 10, bcrypt is still an acceptable password hash. OWASP now recommends it only for legacy systems where Argon2id and scrypt are not available, because bcrypt uses a small, fixed amount of memory and is easier to attack with GPUs than a memory-hard function. If you already use bcrypt, there is no emergency, but new systems should pick Argon2id.
Should I use Argon2i, Argon2d or Argon2id?
Use Argon2id. RFC 9106 makes Argon2id the variant every implementation must support, and OWASP's recommended settings are all for Argon2id. Argon2d is meant for uses without side-channel concerns, such as proof of work, and RFC 9106 describes known trade-off attacks on Argon2i with 1 or 2 passes.
Do I need to store the salt separately?
No. Both bcrypt and Argon2 produce a self-describing string that contains the algorithm, the cost settings and the salt, for example $2b$12$... or $argon2id$v=19$m=65536,t=3,p=4$.... Store that whole string in one column, and the verify function reads the settings back out of it.
What is a pepper, and do I need one?
A pepper is a secret added to every password before hashing and stored outside the database, for example in a secrets manager. OWASP describes it as optional defence in depth: it only helps if an attacker steals the database but not the pepper. It doesn't replace a proper password hash.

Sources