create unique token!!!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jmut
Forum Regular
Posts: 945
Joined: Tue Jul 05, 2005 3:54 am
Location: Sofia, Bulgaria
Contact:

create unique token!!!

Post by jmut »

is this unique enough?

Code: Select all

md5(uniqid(rand(), true));
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Isn't uniqid() unique enough? If not, the function failed its purpose.

With md5() you only gain the possibility of a collision, i.e. the same (and therefore not-so-unique) hash for different input data but no increase in "uniqueness" (as if it's possible anyway ;))
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post by Jenk »

Code: Select all

$new_token = $last_token + 1;
will get you a unique number.
jmut
Forum Regular
Posts: 945
Joined: Tue Jul 05, 2005 3:54 am
Location: Sofia, Bulgaria
Contact:

Post by jmut »

Jenk wrote:

Code: Select all

$new_token = $last_token + 1;
will get you a unique number.
kind of don't want to create file just for that one. token should be unique for each requests.
I don't want to rely on DB...and if not..there are some concurency problems etc that will have to be solved.
Post Reply