Possible Duplicate:
PHP: How to generate a random, unique, alphanumeric string?
I'm trying to generate unique id (alpha-numeric string). I'm using curent timestamp for that. I have two questions:
md5(stamp1)
be different from md5(stamp2)
if stamp1 != stamp2
.PS: the easiest way of cause is to take stamp as id. Still I dont want that it was easy to find out how id is generated
Yes, in most cases, they will be different. Chances of hash collisions are very, very low (think one in billions).
The built in function uniqid()
is great for this. You could even do md5(uniqid())
, but be aware, this won't increase the entropy of the GUID. For increased entropy, you can call the function like this: uniqid('',TRUE);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With