[Math] Calculate password combination with password policy

combinations

Assume user must choose 8 character password using:

  1. lowercase letters a-z (size=26)
  2. uppercase letters A-Z (size=26)
  3. digits 0-9 (size=10)
  4. special characters/symbols (size=33)

policy 1) user can choose password freely

my answer: $95^8$ combinations, since 26+26+10+33 = 95.

policy 2)
The password must at least have one digit or at least one special character.

my answer: number of passwords with at least one digit = $10^8$

number of passwords with at least one special character = $33^8$

number of passwords with at least one digit or at least one special character equals to $10^8$ + $33^8$

are my calculations correct or I am making some stupid mistake?

Best Answer

For your second part, number of valid passwords will be the total number possible minus the invalid ones.

Total number = $(26+26+10+33)^8 = 95^8 $

Invalid ones are those which contain neither a digit nor special character. Thus available characters are only upper and lower case alphabets. Invalid = $(26+26)^8 = 52^8 $

Thus acceptable passwords are: $95^8 - 52^8$

Related Question