Guide Cybersecurity 6 min read

How bcrypt’s 72-byte limit cuts Chinese, Thai and emoji passwords

Bcrypt, the password hash in PHP’s password_hash() and in libraries for Python and Node, reads only the first 72 bytes of a password. We ran 12 builds of it to see what each does with the rest, and how soon Chinese, Thai, Korean and emoji passwords reach the limit.

Kenji Tanaka
Developer Tools & Cloud Analyst
Published 25 Nov 2026, 7:35 AM (SGT)
Share:
A close-up of the keys of a white keyboard, seen at a low angle.
Photo by Pixabay on Pexels
Advertisement

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 ValueError at 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_verify returned true for EXAMPLE plus a NUL and three letters against a hash of EXAMPLE.

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 YBytesPy 3.2.2Py 4.0.1, 4.3.0Py 5.0.0Node, 5 buildsPHPhtpasswd
ASCII, byte 72 differs72nononononono
ASCII, only byte 73 differs73matchmatcherrormatchmatchmatch
24 × 密, last one changed72nononononono
25 × 密, last one changed75matchmatcherrormatchmatchmatch
a + 24 × 密, last one changed to 富73matchmatcherrormatchmatchmatch
19 × 🔑, last one changed76matchmatcherrormatchmatchmatch
abc, NUL, def against abc7 and 3errornononoerrormatch

“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.

Whole characters inside bcrypt’s 72 bytes: 72 in English, about 50 in Vietnamese, 24 in Thai, Chinese and Korean, 18 single emoji. NIST’s 64 characters come to 64 bytes in English, 91 in Vietnamese, 192 in Thai, Chinese and Korean, and 256 in emoji.
Each navy bar ends at byte 72. The dashed outline is NIST’s 64-character allowance converted to UTF-8 bytes. RECATOOLS, measured 24 November 2026 with Python 3.9.6

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.

Bytes 65 to 73 of two 73-byte passwords. Both read E5 AF 86 twice, then E5 AF. Byte 73 is 86 in the first, ending 密, and 8C in the second, ending 富. A line after byte 72 marks where bcrypt stops reading.
Only byte 73 tells 密 from 富 here, and it lies outside the window. RECATOOLS, measured 24 November 2026

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.

Advertisement
Python bcrypt 4.3.0 stores a hash, then 5.0.0 checks it
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 8.5.12, with the same output from 8.4.24
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 character

OWASP 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.

Bcrypt length checks, from OWASP and NIST

0 of 5 done

  1. The count is in UTF-8 bytes. A Han, Thai or Hangul character is 3 bytes, a one-code-point emoji such as 🔑 4.

  2. In 11 of the 12 builds we ran, the library cut silently; the twelfth, Python bcrypt 5.0.0, refuses instead.

  3. In Thai, Han or Hangul that is 192 bytes, past bcrypt’s window.

  4. No library we ran normalises; NFC and NFD forms of one Vietnamese phrase did not match.

  5. Our hash-choice guide has the measured timings.

Your ticks are saved in this browser only.

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.

Advertisement
Kenji Tanaka
Developer Tools & Cloud Analyst

Kenji Tanaka covers developer tools, cloud platforms, DevOps, CI/CD, and software supply-chain topics for RECATOOLS.

View author profile → · Editorial policy

About this byline Kenji Tanaka is a RECATOOLS editorial persona for developer tools, cloud, DevOps, and software supply-chain coverage. Articles are produced and reviewed under RECATOOLS editorial supervision.

Corrections policy

Go further

Relevant tools

More from Cybersecurity

Advertisement
Advertisement