mkropat/MlkPwgen

Always unique

Closed this issue · 2 comments

Hi,

Is the generated password always unique?

Thanks

There is no guarantee the same password won't be generated twice:

PS > 1..10 | foreach { New-Password -Digits -Length 1 }
6
8
8
9
6
3
5
4
7
9

However, if the passwords have enough complexity and/or you aren't generating that many passwords, then the chance of generating two passwords with the same value is nearly 0.

For example, with the default settings each character in the password can be one of 26 + 26 + 10 = 62 possibilities. If you generate a 10 character password, that makes almost a quintillion different possible passwords (62 to the 10th power). Invoking the bithday paradox, you'd have to generate half a quintillion passwords about a million passwords (update: I mathed wrong badly; Math.pow(10, Math.log10(Math.pow(62, 10))/2)) before there'd be a decent chance of generating a duplicate.

@mkropat Thanks that will suffice.