Comment 5 for bug 2028809

Revision history for this message
Dmitriy Rabotyagov (noonedeadpunk) wrote :

Yes, you'r right David, setting `BCRYPT_MAX_LENGTH = 72` is an easy fix. Even setting to 71 would result in invalidly trimmed password.

Though, length should be in bytes, not in string length. So in case 1 symbol takes more then one byte in UTF-8 (like Cyrillic or Chinese), it should be trimmed based on that. Simple example of that:

```
>>> s1 = "%HE"
>>> s2 = "%НЕ"
>>> len(s1)
3
>>> len(s2)
3
>>> len(s1.encode())
3
>>> len(s2.encode())
5
>>>
```