In another question about password generation, I have read an answer suggesting something along the line of:

Let your password manager select characters from all the accepted categories (lowercase, uppercase, digits, standard punctuation, extended ASCII characters) and choose a very long length.
If the target has a shorter maximum length, just generate the longest they'll accept.


Is choosing the maximum-authorized password length a safe strategy?

My reasoning is that — assuming the maximum-authorized password length is long enough (say ≥24 characters), so that high-entropy passwords can still be generated if their length is smaller than the max — choosing a password of length m is much more limiting than choosing a password among those of length m, or m-1, or …, or 25, or 24.

  • A variation of this question is: “Is it safer to generate a 41, 63, or 127-character long password than a 42, 64, or 128 long one, respectively?” as users are more likely to select the latter lengths, so an attacker would try such passwords first? (I.e. a slightly shorter password is better than one that has a “trendy” length.)
    – ebosi
    Commented Jul 27, 2020 at 12:45
  • 1
    It is illogical to try a higher length 1st, so no. The most used password ever was/is 123456 no matter the max length. So I'd rather count on user laziness rather then an user maxing its password.
    – Overmind
    Commented Jul 27, 2020 at 12:47
  • @Overmind of course I'd expect an attacker to try most-used passwords first, then maybe a dictionary attack with common letter/character substitutions. But once they resort in trying brute-force, wouldn't they generate passwords of the max-length before passwords of *max-length*−1? (Or maybe it just doesn't matter because should they have to rely on brute force, I'd be fine for real-life common cases?)
    – ebosi
    Commented Jul 27, 2020 at 12:54
  • 2
    No, because that would take an exponentially higher time.
    – Overmind
    Commented Jul 27, 2020 at 12:55
  • 1
    Starting with the longest passwords first saves very little time, because checking all 19 character passwords takes exactly as long as checking all 20 character passwords which begin with the letter a.
    – Philipp
    Commented Jul 27, 2020 at 14:43

1 Answer 1


Besides dictionary attacks or other possible techniques (like timing attacks, etc.), an attacker might try bruteforcing all the combinations (if possible), or just try some combinations at random (until they give up because it's not worth continuing).

Suppose you have a 24-char alphanumeric password (allowed characters: a-zA-Z0-9), for example 4LZB7NFjpFW6sjtuIaBel9hZ.

  • If the attacker knows the length of your password, the possible combinations to try will be 62^24 = 1.04 * 10^43, which is about 143 bits of entropy.
  • If the attacker does not know the length of your password, the possible combinations will be 62 + 62^2 + ... + 62^23 + 62^24, which is a geometric progression and the result should be ((62^25 -1) / (62 - 1)) - 1 = 1.06 *10^43, still about 143 bits of entropy.
  • If you make the password 1 character shorter and the attacker knows this length, the possible combinations to try will be 62^23 = 1.7*10^41, which is about 137 bits of entropy.

As you can see, even if the attacker knows the exact length of your password, the advantage they might get is negligible. Also, if your password is already very strong, adding or removing one character won't have a significant impact on your security either (anything above 128 bits of entropy is still considered to be uncrackable, even with an enormous amount of computation power).


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .