New answers tagged


Consider null as a valid character to be randomly selected. Remove null characters from the final string. If it is too short, try again.


In practice, it is sufficient to pick a random password with the maximum allowed length. Assuming that your alphabet has $n$ different usable characters, the total number of passwords of length up to $k$ is $$t(k) = n + n^2 + n^3 + \dotsb + n^k = \sum_{j=1}^k n^j = \frac{n^{k+1}-1}{n-1},$$ and thus the fraction of all passwords that have length less than $k$...

Top 50 recent answers are included