Statistics filter: How do I calculate the keyspace size of a password?
August 27, 2011 1:35 AM Subscribe
How do I figure out what the size of this password's keyspace is?
I currently work for a large company with an archaic IT infrastructure and am forced to change my password every 90 days. While I don't specifically think that such a policy is unwarranted, I am constantly annoyed by the arbitrary restrictions that are placed on the passwords that they will allow me to use. I'm currently estimating the total number of distinct passwords that are possible in this system to be in the realm of 160 trillion, an astonishingly small keyspace for a modern password.
Help me figure out what the exact size of the keyspace is given the following requirements:
- Must be exactly 8 characters.
- Must contain at least 1 uppercase character
- Must contain at least 1 lowercase character
- Must contain at least 1 number
- Must contain a leading letter (upper or lower)
- May contain up to 2 special characters ($ or # only)
- May not have repeating characters
posted by vmrob to computers & internet (10 answers total) 2 users marked this as a favorite
Lowercase characters: 26
Digits: 10
Characters including specials (upper, lower, digits, special): 26+26+10+2=64
We have to choose an upper or a lowercase letter first, so we'll say 26*2=52.
Now, the other characters are in no particular order. We want to pick 1 character from the uppercase/lowercase set we didn't use before (from 26), 1 number (from 10), and then five more characters from a set of 61 (none of the characters already picked - so 61 choose 5, or 5949147). Multiplying those together gives us 5949147*26*10 for the seven non-leading characters; putting those into any order we multiply our space by 7!=5040, and then we multiply back in the initial 52 (for our leading character).
This gives us:
5949147*26*10*5040*52, which google says is about 4.05379636 × 10^14
To put this in perspective, compare this with an exactly-8-character password selected only from letters and numbers, with no restrictions like "at least 1 of these" or "no repeating", and you get 62^8 ~= 2.2*10^14.
It's been forever since I did stats, someone please check my math? But I'm reasonably certain the thought process is right.
posted by spaceman_spiff at 2:02 AM on August 27, 2011