### Thread: How Many Possibilities For (32) - Character Alphanumeric String?

1. No Profile Picture
Contributing User
Devshed Newbie (0 - 499 posts)

Join Date
Oct 2002
Posts
372
Rep Power
15

#### 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.
2. 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.
3. No Profile Picture
Contributing User
Devshed Newbie (0 - 499 posts)

Join Date
Oct 2002
Posts
372
Rep Power
15
dog135;

Thank you for the help.
4. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Sep 2005
Posts
1
Rep Power
0
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
5. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Oct 2009
Posts
1
Rep Power
0
To be precise:

for 36 possibilities (a-z & 0-9):
63340286662973277706162286946811886609896461828096

for 16 possibilities (a-f & 0-9):
340282366920938463463374607431768211456

MD5 is the latter, 16 possibilities indeed per character.

#### Comments on this post

• jwdonahue disagrees : You have revived an ancient thread and add nothing of any use to the tribal knowledge.