I am building a small app. I want to generate a random and unique key for each user. If this thing takes off, I might have millions of users! [Coincidentally, this happening is about 1 chance in many millions! :) ]
I need a math person to vet my math here. Do I have this right?
A key will be something like:
X1b-7h4
Each character is random and can be up to 62 different numbers, based on:
. 0-9, a-z, A-Z (So 10 + 26 + 26 possibilities).
. the hyphen does not count (it is for readability)
Is this part right?
For each 3 characters (like "X1b") there are 238,328 possibilities
. as in, 62³
So, if the key is 6 characters it will be:
. 62^6 possibilities (56,800,235,584)
And so on:
. 9 characters is 62^9
. 12 characters is 62^12
. etc, etc
Do I have this right?
Important point: I am not checking each generated key to make sure it is unique, so I need a big enough key to make it (almost) safe to assume this is the case...
Thanks! :)