How many $12$ character passwords include at least one uppercase letter, one lowercase letter, one digit, and one special character?

3.1k Views Asked by At

I have a problem that I can't figure out. The problem is:

How long would it take to guess a $12$ character password containing upper case and lower case letters, digits and $12$ special characters. Assuming that $1$ billion passwords can be guessed every second and there are no repetition of characters. (The password must contain at least 1 upper case, 1 lower case, 1 digit and 1 special character)

So far this is what I got (c = combination): $74$ Total Characters, at least $4$ of these are going to be in password therefore: $$\binom{26}{1}\binom{26}{1}\binom{10}{1}\binom{12}{1} \times \binom{70}{1}\binom{69}{1}\binom{68}{1}\binom{67}{1}\binom{66}{1}\binom{65}{1}\binom{64}{1}\binom{63}{1}\binom{62}{1}$$ $$ = 1.91438 \ldots \times 10^{21}$$ combinations.

which = approx. $1910000000000$ seconds to guess the password.

Is this working correct? Assuming that order within the password is important.

Thanks :)

1

There are 1 best solutions below

4
On BEST ANSWER

There are $26$ uppercase letters, $26$ lowercase letters, $10$ digits, and $12$ special characters, giving a total of $74$ characters. The number of $12$-character passwords that can be formed without repetition is $$P(74, 12) = \binom{74}{12}12!$$ From these, we must subtract those cases in which uppercase letters, lowercase letters, digits, or special characters are missing.

Let $U$, $L$, $D$, and $S$ denote, respectively, the set of $12$-character passwords from which uppercase letters are missing, lowercase letters are missing, digits are missing, and special characters are missing.

What we wish to find is $$P(74, 12) - |U \cup L \cup D \cup S|$$ By the Inclusion-Exclusion Principle, \begin{align*} |U \cup L \cup D \cup S| & = |U| + |L| + |D| + |S|\\ & \quad - |U \cap L| - |U \cap D| - |U \cap S| - |L \cap D| - |L \cap S| - |D \cap S|\\ & \qquad + |U \cap L \cap D| + |U \cap L \cap S| + |U \cap D \cap S| + |L \cap D \cap S|\\ & \quad \qquad - |U \cap L \cap D \cap S| \end{align*}

$|U|$: If uppercase letters are missing, then there are $74 - 26 = 48$ characters available. The number of $12$-character passwords that can be formed without repetition using these $48$-characters is $$P(48, 12)$$

$|L|$: If lowercase letters are missing, then there are $74 - 26 = 48$ characters available. The number of $12$-character passwords that can be formed without repetition using these $48$-characters is $$P(48, 12)$$

$|D|$: If digits are missing, then there are $74 - 10 = 64$ characters available. The number of $12$-character passwords that can be formed without repetition using these $64$-characters is $$P(64, 12)$$

$|S|$: If special characters are missing, then there are $74 - 12 = 62$ characters available. The number of $12$-character passwords that can be formed without repetition using these $62$-characters is $$P(62, 12)$$

$|U \cap L|$: If both uppercase and lowercase letters are missing, then there are $74 - 26 - 26 = 22$ characters available. The number of $12$-character passwords that can be formed without repetition using these $22$-characters is $$P(22, 12)$$

$|U \cap D|$: If both uppercase letters and digits are missing, then there are $74 - 26 - 10 = 38$ characters available. The number of $12$-character passwords that can be formed without repetition using these $38$-characters is $$P(38, 12)$$

$|U \cap S|$: If both uppercase letters and special characters are missing, then there are $74 - 26 - 12 = 36$ characters available. The number of $12$-character passwords that can be formed without repetition using these $36$-characters is $$P(36, 12)$$

$|L \cap D|$: If both lowercase letters and digits are missing, then there are $74 - 26 - 10 = 38$ characters available. The number of $12$-character passwords that can be formed without repetition using these $38$-characters is $$P(38, 12)$$

$|L \cap S|$: If both lowercase letters and special characters are missing, then there are $74 - 26 - 12 = 36$ characters available. The number of $12$-character passwords that can be formed without repetition using these $36$-characters is $$P(36, 12)$$

$|D \cap S|$: If both digits and special characters are missing, then there are $74 - 10 - 12 = 52$ characters available. The number of $12$-character passwords that can be formed without repetition using these $52$-characters is $$P(52, 12)$$

$|U \cap L \cap D|$: If uppercase letters, lowercase letters, and digits are missing, then only the $12$ special characters are left. The number of $12$-character passwords that can be formed without repetition using these $52$-characters is $$P(12, 12)$$

$|U \cap L \cap S|$: If uppercase letters, lowercase letters, and special characters are missing, then only the $10$ digits are left. It is not possible to create a $12$-character password without repetition using fewer than $12$ characters, so the number of $12$-character passwords that can be formed without repetition using these $10$-characters is $$P(10, 12) = 0$$

$|U \cap D \cap S|$: If uppercase letters, digits, and special characters are missing, then only the $26$ lowercase letters are left. The number of $12$-character passwords that can be formed without repetition using these $26$-characters is $$P(26, 12)$$

$|U \cap L \cap D \cap S|$: If uppercase letters, lowercase letters, digits, and special characters are missing, then no characters are left, so it is not possible to form a password. Hence, the number of $12$-character passwords that can be formed without repetition using these $0$-characters is $$P(0, 12) = 0$$

Thus, the number of passwords that violate at least one of the restrictions is \begin{align*} |U \cap L \cap D \cap S| & = P(52, 12) + P(52, 12) + P(64, 12) + P(62, 12)\\ & \quad - P(22, 12) - P(38, 12) - P(36, 12) - P(38, 12) - P(36, 12) - P(52, 12)\\ & \qquad + P(12, 12) + 0 + P(26, 12) + P(26, 12)\\ & \quad \qquad - 0 \end{align*} Hence, the number of admissible passwords is \begin{align*} P(74, 12) & - P(52, 12) - P(52, 12) - P(64, 12) - P(62, 12)\\ & \quad + P(22, 12) + P(38, 12) + P(36, 12) + P(38, 12) + P(36, 12) + P(52, 12)\\ & \qquad - P(12, 12) - P(26, 12) - P(26, 12) \end{align*}