Probability of having exactly $v$ different letters in password Consider a password with $t$ characters, with a character set of length $n^2$. What is the probability there are $v$ distinct letters in the password.
So if the password was "abccdadde" $v$ would be $5$ and $t=9$.
So far I have deduced if $t=n=v$ the probability is given by: $$\frac{n^{2}!}{\left(n^{2}-n\right)!n^{2n}}$$
And when $t=v+1=n+1$ the probability is given by:$$\frac{n\left(n+1\right)!n^{2}!}{2n!\left(n^{2}-n\right)!n^{2\left(n+1\right)}}$$

Denote $n^2=N$ for ease of notation, then the number of ways to assign $v$ "dummy" characters (to be replaced by actual characters later under a bijective map) is the definition of the second-kind Stirling number $S(t,v)$. Then there are ${}^NP_v=\binom Nvv!$ ways to assign the actual characters, so the number of admissible passwords is
$$\binom Nvv!S(t,v)$$
and the probability is this over the total password count $N^t$.
