Key points
- All 12 bcrypt builds we ran on 24 November 2026 read the first 72 bytes of a password. Eleven accepted a password that differed only after byte 72; Python bcrypt 5.0.0 raised an error instead.
- A Chinese, Thai or Korean character is 3 bytes in UTF-8, so 24 of them fill the window. NIST asks verifiers to allow at least 64 characters, which in those scripts is 192 bytes.
- The cut can fall inside a character. 密 and 富 share their first two bytes, so two 73-byte passwords ending in each verified against each other in all 11 truncating builds.
- Python bcrypt 5.0.0 raises at verify as well as at hash, so a long password whose hash was stored under 4.3.0 raises a
ValueErrorat login after the upgrade unless the code cuts it to 72 bytes first. - PHP 8.4.24 and 8.5.12 refuse a NUL byte when hashing, yet
password_verifyreturned true forEXAMPLEplus a NUL and three letters against a hash ofEXAMPLE.
Bcrypt is a password-hashing function, built into PHP’s password_hash() and published as libraries for Python and Node, and it reads at most 72 bytes of a password. On 24 November 2026 we ran 12 builds of it on the same 14 test inputs, and all 12 stopped at byte 72. Eleven quietly accepted a password that differed from the stored one only after that byte, and Python’s bcrypt 5.0.0 raised an error. A Chinese, Thai or Korean character is 3 bytes in UTF-8, so 24 of them fill the window, while the US National Institute of Standards and Technology (NIST) asks verifiers to allow at least 64 characters.
Where every tested library stops reading
For each row we hashed a password, X, at cost 4 and checked a second, Y, against it. They differ only where the row says, so “match” means those bytes were ignored. We ran Python bcrypt 3.2.2, 4.0.1, 4.3.0 and 5.0.0, bcryptjs 2.4.3 and 3.0.3, npm’s native bcrypt 5.1.1 and 6.0.0, PHP 8.4.24 and 8.5.12, Apache htpasswd -B 2.4.67, and our own copy of bcryptjs 2.4.3.
| X against Y | Bytes | Py 3.2.2 | Py 4.0.1, 4.3.0 | Py 5.0.0 | Node, 5 builds | PHP | htpasswd |
|---|---|---|---|---|---|---|---|
| ASCII, byte 72 differs | 72 | no | no | no | no | no | no |
| ASCII, only byte 73 differs | 73 | match | match | error | match | match | match |
| 24 × 密, last one changed | 72 | no | no | no | no | no | no |
| 25 × 密, last one changed | 75 | match | match | error | match | match | match |
| a + 24 × 密, last one changed to 富 | 73 | match | match | error | match | match | match |
| 19 × 🔑, last one changed | 76 | match | match | error | match | match | match |
| abc, NUL, def against abc | 7 and 3 | error | no | no | no | error | match |
“Node, 5 builds” covers both bcryptjs versions, both native versions and our copy, which behaved alike. We read two more implementations in source without running them. Go’s x/crypto/bcrypt has refused passwords over 72 bytes in GenerateFromPassword since a commit of 21 December 2022, first tagged in v0.5.0. OpenBSD’s bcrypt.c, revision 1.58, caps the key at 72 bytes for the $2b$ hashes it writes.
Byte budgets for Thai, Han, Hangul and emoji
NIST counts password length in characters. Its SP 800-63B-4, section 3.1.1.2, says verifiers “SHOULD permit a maximum password length of at least 64 characters”, with each Unicode code point counted as one. Bcrypt counts bytes, and in Thai, Han or Hangul 64 characters come to 192 of them.
Our Vietnamese sample, mật khẩu của tôi rất dài (“my password is very long”), averaged 1.42 bytes a character in its composed NFC form, so about 50 fit. A family emoji of three joined people is 18 bytes, so four fill the window.
Half a character still counts toward the hash
The point between bytes 72 and 73 need not fall between characters. Take the letter a and 24 copies of 密 (mì), 73 bytes in all, and a second password ending in 富 (fù). Their last characters, E5 AF 86 and E5 AF 8C, differ only in the third byte, which falls outside the window. All 11 truncating builds treated the two as one password.
Our bcrypt generator runs the bcryptjs 2.4.3 copy in the table, in the browser. A counter under each password field shows the UTF-8 bytes against 72 as you type. For the letter a followed by 24 copies of 密, it says the window holds 24 of the 25 characters and the first 2 of the 3 bytes of the last one. The page times each hash on your device, beside one labelled measurement of ours, and refuses to check a hash made above cost 14, so a pasted hash cannot freeze the tab.
Refusing long passwords moves the failure to login
The pyca project’s bcrypt changelog says that from 5.0.0, uploaded to PyPI on 25 September 2025, a password over 72 bytes passed to hashpw “now raises a ValueError”. The entry names hashpw only, but checkpw raises too, so a 78-byte passphrase whose hash was stored under 4.3.0 raises an error at login after the upgrade.
py-4.3.0/bin/python -c 'import bcrypt; pw = b"EXAMPLE-only-" * 6; h = bcrypt.hashpw(pw, bcrypt.gensalt(4)); open("h.txt", "wb").write(h); print(bcrypt.__version__, len(pw), bcrypt.checkpw(pw, h))'
4.3.0 78 True
py-5.0.0/bin/python -c 'import bcrypt; pw = b"EXAMPLE-only-" * 6; h = open("h.txt", "rb").read(); print(bcrypt.checkpw(pw, h))'
ValueError: password cannot be longer than 72 bytes, truncate manually if necessary (e.g. my_password[:72])Go’s library, per its source, checks only when a hash is generated. The bcryptjs 3.0.0 release of 13 February 2025 added a truncates() helper and leaves the choice to the caller. Laravel’s BcryptHasher (v13.15.0) has an optional limit, off by default, that throws on input over it.
Embedded NUL bytes behave four ways
A NUL is byte 00, which C treats as the end of a string. Python bcrypt 3.2.2 refused it at hash and at verify. Python bcrypt 4.0 and later, and both Node libraries, read past it, and htpasswd stopped at it, as OpenBSD’s source reads a key.
PHP 8.3.6, released on 11 April 2024, fixed CVE-2024-3096, where a stored password beginning with a NUL let a blank string verify, by adding a NUL check to hashing. In our runs on 8.4.24 and 8.5.12, password_verify still returned true for a password with a NUL and extra letters after it.
php -r 'var_dump(password_verify("EXAMPLE\0zzz", password_hash("EXAMPLE", PASSWORD_BCRYPT)));'
bool(true)
php -r 'try { password_hash("EXAMPLE\0zzz", PASSWORD_BCRYPT); } catch (ValueError $e) { echo $e->getMessage(), "\n"; }'
Bcrypt password must not contain null characterOWASP and NIST pull in different directions
The Open Worldwide Application Security Project (OWASP) Password Storage Cheat Sheet, read on 24 November 2026, says bcrypt has “a maximum length input length of 72 bytes for most implementations, so you should enforce a maximum password length of 72 bytes”. It places bcrypt in “legacy systems where Argon2 and scrypt are not available”. NIST says verifiers “SHALL verify the entire submitted password (e.g., not truncate it)”.
For an English password the two fit together. For a Han or Thai one, OWASP’s cap stops at 24 characters, against NIST’s 64. OWASP says pre-hashing to get past the limit “can be dangerous” because of NUL bytes in the hash output and password shucking, and gives bcrypt(base64(hmac-sha384(...))) with the pepper stored “not in the database”. Cost settings and their timings are measured in our guide to choosing a hash.
In Thai, Han or Hangul, the 64 characters NIST asks verifiers to allow come to 192 bytes, and bcrypt reads the first 72.
NIST also asks a verifier accepting Unicode to apply NFC normalisation, which stores each accented letter or Hangul syllable as one composed code point, and none of the libraries we ran does. The composed NFC and decomposed NFD forms of mật khẩu của tôi, 23 and 28 bytes, did not verify against each other in any of the 12 builds, and neither did the two forms of the Korean 비밀번호.
Checking a login stack against the published guidance
Each line is the cheat sheet’s or NIST’s own requirement, with what our runs add.
Upgrading to a refusing release
Python bcrypt 5.0.0 raised ValueError when verifying a long password against a hash stored by 4.3.0. In our run, cutting the password to its first 72 bytes before checkpw returned True, the step the error message itself names.
That restores the 4.3.0 behaviour, which NIST’s line about not truncating the password asks verifiers to avoid.
Versions, scripts and what will date this
All runs were on 24 November 2026, Singapore time, on an Apple Silicon Mac (macOS 26) at cost 4, so they record behaviour and no timings. Python bcrypt ran under Python 3.9.6, the Node libraries under Node 26.13.0. Per-library write-ups of the limit already exist, among them pyca’s README and the Stack Exchange thread the cheat sheet links. NIST’s publication record gives July 2025 as the date SP 800-63B-4 was published. A new release of pyca bcrypt, bcryptjs or the native bcrypt package can change its column, and a new x/crypto release can change what Go’s source says.
Go further
Relevant tools
More from Cybersecurity