December 23rd, 2003, 10:08 PM
How Many Possibilities For (32) - Character Alphanumeric String?
How many possible combinations is there with a thirty-two (32) character string where each character has to be alphanumeric?
If I'm figuring it right, and I'm not at all sure that I am, the answer would be *36 x 36 x 36 .... and so forth for a total of thirty-two multiples.
(i.e. 1-0 and a-z, thirty-six possibilities for each character)*
Using my Lotus 1-2-3 spreadsheet, I get an answer of 6.33402866629733E+049 for the thirty-second calculation. I know it's a larger number but I'm not sure exactly what it means.
The reason that I ask the above is that I'm working on a user registration script for a web site. What I'm wanting to do is assign a unique user id for each user. I am applying the PHP "md5()" function to each registrant's username in order to get a thirty-two character string that I can use as a unique id.
All this is probably a moot point since each username (no two usernames can be alike in my database) will yield a different thirty-two character string when I apply the md5() function to it.
I'm just trying to sort through all of this and think it through in order to minimize the potential for my web site crashing a few months down the road.
December 24th, 2003, 01:17 PM
36^32 (thirtysix to the power of thirtytwo) is the correct answer. Basically what you did.
When it says "E+" it means, that's how many places you move the decimal over. So roughly:
Big number, huh?
In SQL, for my IDs, I usually use, "id int(6) auto_increment primary key". That'll make an integer that's always unique for each record.
It is possible that two different user names return the same md5 value. But just check the uniqueness based on the md5 and not the name itself, and you should be fine.
"Science is constructed of facts as a house is of stones. But a collection of facts is no more a science than a heap of stones is a house." - Henri Poincare
December 24th, 2003, 01:23 PM
Thank you for the help.
September 5th, 2005, 06:42 AM
Okay, I know this is quite old thread but I happend to stumble across this while looking for the amount of possible combinations for a md5 hash. (Okay, so maybe I should have just thought it through and use the calculator to get the answer but google was open on my browser so I just went for it)
So the above answer is correct for a 32-character alphanumeric string but md5 hash is a 32-character hexadecimal number. So there are only 16 possible values (0-9 and a-f) and not 36. Using the same equation as above we get the correct answer which is 16^32 (3,4028236692093846346337460743177e+38)
But that should be enough anyway
October 21st, 2009, 08:25 AM
To be precise:
for 36 possibilities (a-z & 0-9):
for 16 possibilities (a-f & 0-9):
MD5 is the latter, 16 possibilities indeed per character.
Comments on this post