I am generating tokens for users in PHP when they register. I am wondering if two users could ever get the same token... as this will break the system. Please let me know if this is suffiecient.
$token = md5(rand().time());
edit: i am now using a generate_uuid() function i found on another question.
will this work?
function generate_uuid() {
return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ),
mt_rand( 0, 0xffff ),
mt_rand( 0, 0x0C2f ) | 0x4000,
mt_rand( 0, 0x3fff ) | 0x8000,
mt_rand( 0, 0x2Aff ), mt_rand( 0, 0xffD3 ), mt_rand( 0, 0xff4B )
);
}
question from:
https://stackoverflow.com/questions/65648350/will-time-ever-return-the-same-output 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…