December 23rd, 2003, 09:08 PM

How Many Possibilities For (32)  Character Alphanumeric String?
How many possible combinations is there with a thirtytwo (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 thirtytwo multiples.
(i.e. 10 and az, thirtysix possibilities for each character)*
Using my Lotus 123 spreadsheet, I get an answer of 6.33402866629733E+049 for the thirtysecond 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 thirtytwo 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 thirtytwo 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, 12: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:
63340000000000000000000000000000000000000000000000
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, 12:23 PM

dog135;
Thank you for the help.
September 5th, 2005, 05: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 32character alphanumeric string but md5 hash is a 32character hexadecimal number. So there are only 16 possible values (09 and af) 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, 07:25 AM

To be precise:
for 36 possibilities (az & 09):
63340286662973277706162286946811886609896461828096
for 16 possibilities (af & 09):
340282366920938463463374607431768211456
MD5 is the latter, 16 possibilities indeed per character.
Comments on this post