The salt appears to have a maximum length after which it has no longer impacts the generated hash.
Here some examples:
Hashids.new('a' * 41).encode(1)
=> "pn"
Hashids.new('a' * 42).encode(1)
=> "nd"
Hashids.new('a' * 43).encode(1)
=> "yQ"
Hashids.new('a' * 44).encode(1)
=> "yQ"
Hashids.new('a' * 45).encode(1)
=> "yQ"
If i change the alphabet it also affects this maximum length:
Hashids.new('a' * 22, 0, 'abcdefghijkmnopqrstuvwxyz023456789').encode(1)
=> "b0"
Hashids.new('a' * 23, 0, 'abcdefghijkmnopqrstuvwxyz023456789').encode(1)
=> "bd"
Hashids.new('a' * 24, 0, 'abcdefghijkmnopqrstuvwxyz023456789').encode(1)
=> "bd"
Hashids.new('a' * 25, 0, 'abcdefghijkmnopqrstuvwxyz023456789').encode(1)
=> "bd"
Looks like something around (alphabet.length * 0.7).floor is the maximum length?
Should this be validated and raise a SaltError when the salt is too long?
The salt appears to have a maximum length after which it has no longer impacts the generated hash.
Here some examples:
If i change the alphabet it also affects this maximum length:
Looks like something around
(alphabet.length * 0.7).flooris the maximum length?Should this be validated and raise a
SaltErrorwhen the salt is too long?