I am using
uniqid(md5(time(),false)).uniqid(md5(rand(),false));
to generate unique string. Is this safe to use or there is a chance of collisions? What would you recommend me to use?
I am using
uniqid(md5(time(),false)).uniqid(md5(rand(),false));
to generate unique string. Is this safe to use or there is a chance of collisions? What would you recommend me to use?
md5 with time will generate a new unique id evert time but as you are randomizing this generate value there is some chances of collision Instead you can do it like below function
function newId() { return uniqid() . '_' . md5(mt_rand()); }
It will generate a uniqueid and append md5 random value to it so it will always be unique and will be very deficult to brutforce this.