password_hash() with bcrypt has two long-standing traps. It only reads the first 72 bytes of a password, and null bytes cause trouble. Andrey Andreev's RFC adds a new algorithm, PASSWORD_BCRYPT_WRAP, that keeps bcrypt but runs the password through another hash first (a "prehash"), so the whole password counts.
$password = "A really, really long passw\x0rd, that's over 72 bytes and also includes a null byte"; $hash = password_hash($password, PASSWORD_BCRYPT_WRAP); // $bcrypt-wrap$v=0$cost=12,prehash=cshake256$+Thtm389lrboo7t9btjPVw$t76sKAokMxK5jjH918oNiRRXu0WWxd0 var_dump(password_verify($password, $hash)); // bool(true) var_dump(password_verify($password . " + bcrypt would ignore this", $hash)); // bool(false)
How it works
The algorithm, named bcrypt-wrap, hashes the password with its salt, then hands the result to bcrypt. A prehash option picks the first hash:
cshake256, the default. cSHAKE256 is a SHA-3 family function standardized by NIST.sha512, used as an HMAC.
$hash = password_hash($password, PASSWORD_BCRYPT_WRAP, ["cost" => 4, "prehash" => "sha512"]); // $bcrypt-wrap$v=0$cost=4,prehash=sha512$jjAqrmWi61kah3sXIk4uLQ$Lru7YmJuOYolnxjzxJzvew2h5S7QBSQ
It uses bcrypt's default cost, and passwords are capped at 1,024 bytes to stop extreme misuse. The stored hash follows the PHC string format, a cross-language standard, so the version, cost and prehash are spelled out and other languages can implement it. password_get_info() reports the algorithm as bcrypt-wrap with its cost and prehash options.
A second answer to the same problem
This is the second recent RFC to fix the 72-byte limit with a prehash. Sjoerd Langkemper's bcrypt_sha256 RFC ports the bcrypt_sha256 format from Python's Passlib. Andrey argues that SHA-256 is cheaper to crack on GPUs than the two hashes he picked, and that PHP shouldn't inherit Passlib's legacy. He thanked Sjoerd for holding back that proposal while he finished this one. A third RFC, bcrypt_max_password_length, takes another route and rejects bcrypt passwords over 72 bytes.
What it means for existing code
Nothing breaks. PASSWORD_BCRYPT_WRAP is opt-in, and existing hashes keep working. ext/standard will depend on ext/hash, which is always available now. The RFC lists making it PASSWORD_DEFAULT in a later major version as future scope.
Where it stands
Andrey Andreev opened the internals discussion on October 29, 2026, targeting PHP 8.7, with pull request #25040. Kamil Tekiela replied that the design lowers bcrypt's security and is open to hash shucking (cracking the inner hash with leaked hashes from other sites). Andrey rejected both points, citing the domain separation built into the prehash. Tim Düsterhus asked for a pseudocode description of the construction and a clearer account of how it improves on bcrypt_sha256. Sjoerd Langkemper compared the two RFCs, found both secure, and warned that voting on them separately could go badly, since PHP only needs one. Version 1.1 of the RFC, on November 2, added pseudocode for hashing and verifying, a longer comparison with bcrypt_sha256, and answers on hash shucking and input space. Andrey also asked the list whether prehash=sha512 should become prehash=hmacsha512, so that option name may change. Acceptance needs a two-thirds majority. No vote has been scheduled yet.