Skip to content

Commit c31d9cd

Browse files
committed
Switch from 255 char max to 72
1 parent 2649bd7 commit c31d9cd

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/bcrypt/engine.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,13 @@ class Engine
88
# The maximum cost supported by the algorithm.
99
MAX_COST = 31
1010
# Maximum possible size of bcrypt() secrets.
11+
# Older versions of the bcrypt library would truncate passwords longer
12+
# than 72, but newer ones do not. We truncate like the old library for
13+
# forward compatibility. This way users upgrading from Ubuntu 18.04 to 20.04
14+
# will not have their user passwords invalidated, for example.
15+
# A max secret length greater than 255 leads to bcrypt returning nil.
1116
# https://github.com/bcrypt-ruby/bcrypt-ruby/issues/225#issuecomment-875908425
12-
MAX_SECRET_LENGTH = 255
17+
MAX_SECRET_LENGTH = 72
1318
# Maximum possible size of bcrypt() salts.
1419
MAX_SALT_LENGTH = 16
1520

0 commit comments

Comments
 (0)