symfony/password-hasher
Symfony's PasswordHasher component provides secure password hashing utilities, with a factory to configure multiple algorithms like bcrypt and sodium. Hash plain passwords and verify them easily in your PHP applications.
symfony/symfony, so the code is exercised at massive scale. Building an equivalent in-house is a poor use of engineering time.PasswordHasherFactory named-hasher model supports a genuine roadmap item: per-tenant or per-role algorithm tiers (enterprise tenants on Argon2id, standard accounts on bcrypt). If no such requirement exists, this decision resolves to "tune Laravel's Hash cost factor" and the evaluation closes — that's a valid, cheap outcome.needsRehash() is the actual product value here. It turns "rehash on successful login" from a bespoke subsystem into a one-line check plus a listener. That makes algorithm upgrades a repeatable policy operation rather than a project.LegacyPasswordHasher and MigratingPasswordHasher give a verifiable bridge with a defined removal date instead of a permanent compatibility scar.Consider it when at least one of these is true:
hash / verify / needsRehash contract.security-bundle and should not install it directly.Look elsewhere or defer when:
Illuminate\Hashing wraps password_hash()/password_verify() and already satisfies NIST 800-63B and OWASP guidance with a sane cost factor. Adopting this is dependency surface with no behavioural gain.Illuminate\Contracts\Hashing\Hasher adapter, a service-provider binding, and a login listener. Budget 0.5 day for a proof of concept, 1–2 weeks for production rollout across web, API, password reset, and admin — plus tests proving old hashes still authenticate.To executives: This is a small, free, security-reviewed component from Symfony that lets us support more than one password-hashing standard at once and upgrade old password hashes automatically as users log in. It's the buy option in a build-vs-buy call we'd otherwise make badly. It doesn't touch our database schema, it doesn't require a bulk data migration (password hashes can't be recomputed without plaintext — the industry-standard approach is upgrade-on-login), and it's MIT-licensed with no meaningful supply-chain exposure.
To engineering: It's not a Laravel package and it doesn't replace Hash. It's a Symfony component we'd wrap in an adapter behind Illuminate\Contracts\Hashing\Hasher. The value is the PasswordHasherFactory named-hasher model and needsRehash(). The real work isn't the adapter — it's the rehash-on-login listener, the legacy verifier, and the tests. It's security-critical code: bugs mean account takeover or lockout, so this gets a proper review and staged rollout, not a Friday ship.
What I need to decide to proceed: (1) Do we actually need multi-algorithm hashing, or is the requirement "bcrypt with a sane cost"? (2) What's the PHP floor across adopting services — that picks the branch. (3) Who owns the rehash login hook and what's the rollback if the rehash write fails mid-login? (4) What's our p95 login latency SLO, and what cost factor fits inside it at peak? (5) How many legacy formats must stay verifiable, and until when — that defines the bridge's removal ticket.
The honest recommendation: if the answers to (1) are "no, not really," we tune Hash and close this. If they're "yes, we have legacy rows and a tiered policy," this is the right tool and the effort is small and well-understood.
How can I help you explore Laravel packages today?