How bcrypt and Argon2id compare for storing passwords in 2026: what each defends against, the OWASP parameters, bcrypt's 72-byte limit, memory cost and server sizing, hash formats, and migrating existing bcrypt hashes to Argon2id on login, with a Go implementation in an Encore service.

Every backend that stores passwords picks a hash once and rarely revisits it, so a lot of production systems still run bcrypt chosen around 2012. bcrypt has aged well, and the question now is whether a new system should start with Argon2id instead and whether an existing one should migrate.
This guide compares the two on attacker cost, parameters, limits and operations, then shows a Go migration path.
The OWASP Password Storage Cheat Sheet puts it in one line: use Argon2id with at least 19 MiB of memory, two iterations and one degree of parallelism, fall back to scrypt, and use bcrypt with a work factor of 10 or more only for legacy systems.
Offline cracking happens after a database leak, on hardware the attacker picks. bcrypt's cost is mostly CPU time with a small fixed memory footprint, and its 4 KB state fits in the fast memory of a GPU core, so cracking rigs can run many guesses in parallel. Argon2id makes each guess fill and read a block of memory of the size you choose, so a GPU with thousands of cores runs out of memory bandwidth long before it runs out of cores. Raising the memory parameter raises the attacker's cost per guess in a way bcrypt's single knob cannot.
For the defender, the same property is a cost to plan for. Each concurrent login holds that memory for the duration of the hash, so 50 logins at once at 19 MiB need close to 1 GB, which matters on small containers. A login endpoint should have a concurrency limit or a rate limit anyway, and with Argon2id it also protects the instance's memory.
bcrypt only uses the first 72 bytes of its input. A passphrase of 80 characters is effectively truncated, and two long passwords that start with the same 72 bytes produce the same hash. Multi-byte UTF-8 characters reach the limit sooner. Libraries handle it differently: some truncate silently, and Go's golang.org/x/crypto/bcrypt returns "password length exceeds 72 bytes" as an error, which at least makes the limit visible. Pre-hashing with SHA-256 before bcrypt works around it, but it has to be done carefully, encoding the digest as base64 so it contains no null bytes, and it is one more custom step that Argon2id does not need.
The right target is set by your hardware and login volume: fast enough that a login stays responsive and a burst of logins does not exhaust CPU or memory, slow enough that an offline guess is expensive. Measure on production instance sizes, raise Argon2id's memory before its iterations, and store the parameters in each hash so you can raise them later without breaking old hashes.
Both store everything needed to verify in one string. bcrypt uses the modular crypt format, $2b$12$ followed by the salt and hash. Argon2id uses the PHC string format, with the variant, version, parameters, salt and hash, for example $argon2id$v=19$m=19456,t=2,p=1$<salt>$<hash>. Storing parameters per hash is what makes upgrades possible: verify with the parameters in the string, then rehash with today's parameters when they are lower.
Both algorithms live in golang.org/x/crypto, and this file hashes new passwords with Argon2id, verifies both formats, and tells the caller when a stored hash should be replaced:
// users/password.go
package users
import (
"crypto/rand"
"crypto/subtle"
"encoding/base64"
"errors"
"fmt"
"strings"
"golang.org/x/crypto/argon2"
"golang.org/x/crypto/bcrypt"
)
// OWASP minimum for Argon2id: 19 MiB of memory, 2 iterations, 1 degree of parallelism.
const (
argonMemoryKiB = 19 * 1024
argonTime = 2
argonThreads = 1
argonKeyLen = 32
saltLen = 16
)
var b64 = base64.RawStdEncoding
// HashPassword returns an Argon2id hash in the PHC string format.
func HashPassword(password string) (string, error) {
salt := make([]byte, saltLen)
if _, err := rand.Read(salt); err != nil {
return "", err
}
key := argon2.IDKey([]byte(password), salt, argonTime, argonMemoryKiB, argonThreads, argonKeyLen)
return fmt.Sprintf("$argon2id$v=%d$m=%d,t=%d,p=%d$%s$%s",
argon2.Version, argonMemoryKiB, argonTime, argonThreads, b64.EncodeToString(salt), b64.EncodeToString(key)), nil
}
// VerifyPassword checks a password against an Argon2id or legacy bcrypt hash.
// needsRehash is true when the stored hash should be replaced with a fresh Argon2id hash.
func VerifyPassword(password, encoded string) (ok, needsRehash bool, err error) {
if strings.HasPrefix(encoded, "$2a$") || strings.HasPrefix(encoded, "$2b$") || strings.HasPrefix(encoded, "$2y$") {
err := bcrypt.CompareHashAndPassword([]byte(encoded), []byte(password))
if errors.Is(err, bcrypt.ErrMismatchedHashAndPassword) {
return false, false, nil
}
return err == nil, err == nil, err
}
var version int
var memory, iterations uint32
var threads uint8
parts := strings.Split(encoded, "$")
if len(parts) != 6 || parts[1] != "argon2id" {
return false, false, errors.New("unknown hash format")
}
if _, err := fmt.Sscanf(parts[2], "v=%d", &version); err != nil || version != argon2.Version {
return false, false, errors.New("unsupported argon2 version")
}
if _, err := fmt.Sscanf(parts[3], "m=%d,t=%d,p=%d", &memory, &iterations, &threads); err != nil {
return false, false, err
}
salt, err := b64.DecodeString(parts[4])
if err != nil {
return false, false, err
}
want, err := b64.DecodeString(parts[5])
if err != nil {
return false, false, err
}
got := argon2.IDKey([]byte(password), salt, iterations, memory, threads, uint32(len(want)))
if subtle.ConstantTimeCompare(got, want) != 1 {
return false, false, nil
}
outdated := memory < argonMemoryKiB || iterations < argonTime || threads != argonThreads
return true, outdated, nil
}
The comparison uses subtle.ConstantTimeCompare, and a bcrypt match returns needsRehash so the caller upgrades it in the same request. A unit test that hashes and verifies a known password, checks that a wrong one fails and that a bcrypt hash triggers a rehash covers the main paths, and it ran clean against Go 1.27 with golang.org/x/crypto.
Encore is a backend framework with built-in infrastructure, and the users service below keeps its password hashes in a Postgres database declared in the same package. The login endpoint verifies either format and, on a successful bcrypt match, writes an Argon2id hash in its place, so the migration happens as users sign in.

Run in your terminal to get started locally.
The users table stores one hash string per account:
-- users/migrations/1_users.up.sql
CREATE TABLE users (
id BIGSERIAL PRIMARY KEY,
email TEXT NOT NULL UNIQUE,
password_hash TEXT NOT NULL,
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
);
Signup hashes with Argon2id, and login upgrades old hashes:
// users/users.go
package users
import (
"context"
"errors"
"strings"
"encore.dev/beta/errs"
"encore.dev/rlog"
"encore.dev/storage/sqldb"
)
var db = sqldb.NewDatabase("users", sqldb.DatabaseConfig{Migrations: "./migrations"})
// dummyHash keeps the response time similar for unknown emails.
var dummyHash, _ = HashPassword("not a real password")
type Credentials struct {
Email string `json:"email"`
Password string `json:"password"`
}
type SignupResponse struct {
ID int64 `json:"id"`
}
//encore:api public method=POST path=/signup
func Signup(ctx context.Context, p *Credentials) (*SignupResponse, error) {
if len(p.Password) < 12 || len(p.Password) > 256 {
return nil, errs.B().Code(errs.InvalidArgument).Msg("password must be 12 to 256 characters").Err()
}
hash, err := HashPassword(p.Password)
if err != nil {
return nil, err
}
var id int64
err = db.QueryRow(ctx, `
INSERT INTO users (email, password_hash) VALUES (lower($1), $2) RETURNING id
`, strings.TrimSpace(p.Email), hash).Scan(&id)
if err != nil {
return nil, errs.B().Code(errs.AlreadyExists).Msg("could not create account").Err()
}
return &SignupResponse{ID: id}, nil
}
type LoginResponse struct {
UserID int64 `json:"user_id"`
}
//encore:api public method=POST path=/login
func Login(ctx context.Context, p *Credentials) (*LoginResponse, error) {
invalid := errs.B().Code(errs.Unauthenticated).Msg("invalid email or password").Err()
var id int64
var stored string
err := db.QueryRow(ctx, `SELECT id, password_hash FROM users WHERE email = lower($1)`,
strings.TrimSpace(p.Email)).Scan(&id, &stored)
if errors.Is(err, sqldb.ErrNoRows) {
VerifyPassword(p.Password, dummyHash)
return nil, invalid
} else if err != nil {
return nil, err
}
ok, needsRehash, err := VerifyPassword(p.Password, stored)
if err != nil || !ok {
return nil, invalid
}
if needsRehash {
if fresh, err := HashPassword(p.Password); err == nil {
_, err = db.Exec(ctx, `UPDATE users SET password_hash = $1 WHERE id = $2 AND password_hash = $3`, fresh, id, stored)
if err != nil {
rlog.Error("password rehash failed", "user_id", id, "err", err)
}
}
}
return &LoginResponse{UserID: id}, nil
}
The AND password_hash = $3 condition keeps two concurrent logins from overwriting each other's rehash, and a failed rehash only logs, since the user did authenticate. Unknown emails still run a full Argon2id verification against a dummy hash, so response time does not reveal which emails have accounts. encore run starts Postgres locally and applies the migration, so a bcrypt hash inserted by hand can be watched turning into an Argon2id hash after one login. Importing the old users table from another database is a normal migration file or a one-off encore db shell session.
An agent tightening the policy later, for example raising Argon2id memory to 46 MiB, changes one constant, and the same needsRehash path upgrades every hash as users sign in.
Best fit: Backends with an existing bcrypt user table that want new hashes in Argon2id and old ones upgraded gradually, with the users database in the same service as the login code.
Yes, for new systems. Argon2id is memory-hard, so each guess needs a configurable amount of RAM, which makes GPU and ASIC cracking far more expensive than against bcrypt's fixed 4 KB. bcrypt with a cost of 10 or more is still acceptable for existing systems, and OWASP lists it for legacy use.
OWASP's minimum is 19 MiB of memory, 2 iterations and a parallelism of 1. Raise memory first if your servers can afford it, and measure the time per hash on production hardware, aiming for well under a second.
bcrypt only uses the first 72 bytes of the password, so longer passwords that share a 72-byte prefix hash the same. Some libraries silently truncate, while Go's golang.org/x/crypto/bcrypt returns an error for longer input, and Argon2id has no such limit.
Keep verifying existing bcrypt hashes, and when a user logs in successfully, hash the password they submitted with Argon2id and replace the stored hash. Users who never log in keep bcrypt hashes, which you can expire with a forced password reset later.
Yes. An Encore service can declare a Postgres database in the same package as the login endpoint, and on deploy Encore provisions the database in your own AWS or GCP account. The login code can verify bcrypt hashes and upgrade them to Argon2id as users sign in.
Deploy to your cloud on AWS and Google Cloud
without managing infrastructure
Encore lets developers and agents define application infrastructure directly in code, then automatically provisions it from local development to production in your AWS or GCP account.