# Password strength and number of digits and symbols

Hi.

I've been wondering for a while now why the password generator doesn't allow me to generate truly fully random passwords. Why do I get to set the number of digits and symbols in the password? Because as it is, I've just set this to some value and don't usually change it for every password I generate.
Doesn't that take away a big chunk of randomness from my passwords?

I realize there are situations where you have to have a minimum number of symbols in your password, for example. But even then, a minimum setting would still be better than a fixed number. For most other websites a fully random setting would be totally fine.

Or maybe it's been there all along and I just managed to miss it all this time. Please enlighten me Regards,
Moritz

• Agile Customer Care Team Member
That is a great observation, Moritz!

First the rationale of the current system is that there are still web pages that have requirements like "exactly 2 digits" and so on. You are correct that these do, in general, reduce the entropy, but in practice it doesn't do so by much.

I've actually been trying to figure out the precise formula for the settings of "N symbols and M digits and total length L", but it is a bit trickier than I first imagined.

But lets work though a specific example. Suppose we have a password of length 15 with "exactly 2 digits" and "at least 2 digits".

In the first case, there will be 13 letters (so 52^{13} possibilities) and 2 digits (10^2) and then there will be 15 places one digit can go and 14 positions the other digit can appear. So this is a total of

52^13 * 10^2 * 15 * 14 = 4.268376911e26

That will work out to 88 bits of entropy.

The calculation for "at least 2" is trickier (at least for me). First lets start with if we have any number of digits. So this will be (52+10)^15 possibilities. But then we need to subtract out the ones that have fewer than 2 digits.

The number that could have zero digits would be 52^10. And the number that have exactly one digit is 52^14 * 10 * 15 (the last "15" is for the number of positions the digit could occupy.)

So the grand total of possibilities for "length 15, at least 2 digits" is

(52+10)^15 - 52^10 - (10*15) = 7.689097048e26

And that works out to 89 bits of entropy.

So going with "exactly 2" instead of "at least 2" we have lost one bit of entropy.

Again, I haven't worked out a general formula for this, but I've worked through the calculations with a number of plausible examples and have not found a plausible case where there is a substantial difference.

So yes, you are correct. The system in the Strong Password Generator throws away some randomness, but it turns out that it isn't enough to make a practical difference.

Cheers,

-j
• Sorry, took me a while to wrap my head around this sort of math and I admit it's still a bit over my head. But I do believe that your calculation is off. At least the first one.

As far as I understand it 10^2 accounts for all sequences of two digits, such as [3,7] and [7,3] (those are two distinct sequences that are both covered by 10^2). But when you multiply that by 15 * 14, you're actually allowing the second digit to be placed left of the first one. This would result in a different sequence of digits -- turning [3,7] into [7,3].
Basically, you're counting each sequence more than once, I think.
Of course, I have no idea how to calculate the correct number or even if this supposed error has any significant impact. You're argument might still hold.

I tried to come up with my own example, comparing a fully random 15 character password to a mixture of 5 letters, 5 symbols and 5 digits. Let's just say I failed horribly, actually ending up with a higher number for the more restricted password.
• I have just been wondering, what is the appropriate ratio of numbers to use with a given password length? How about symbols (the ones that you currently use)? So, for a password of, say, 15 characters, how many numbers, symbols, and letters should we have to maximize the password's strength?
• Social Choreographer Team Member
tatchley, I've merged your post with this existing thread as I believe it is directly related. The element of a password which affects it most dramatically is its length, much more so than its "complexity" (i.e., digits and symbols).

Please see above and let me know if you have any additional questions.