I\'d like to generate a secure one-click-access type of url similar to the examples below. I\'ll be using PHP but that is irrelevant as I\'m just looking to understand the under
Just generate a GUID. It is important though that is isn't an old-style sequential GUID though.
However it appears that php doesn't have its own GUID generating function. The com_create_guid function suggested in another answer appears to only be available in php when running on Windows.
There is a user suggested alternative for com_create_guid for non-Windows on the manual page for it:
function guid(){
if (function_exists('com_create_guid')){
return com_create_guid();
}else{
mt_srand((double)microtime()*10000);//optional for php 4.2.0 and up.
$charid = strtoupper(md5(uniqid(rand(), true)));
$hyphen = chr(45);// "-"
$uuid = chr(123)// "{"
.substr($charid, 0, 8).$hyphen
.substr($charid, 8, 4).$hyphen
.substr($charid,12, 4).$hyphen
.substr($charid,16, 4).$hyphen
.substr($charid,20,12)
.chr(125);// "}"
return $uuid;
}
}
But I have to admit I'd be reluctant to use it for anything important in case there was an non obvious problem lurking in it that my non-cryptographically trained mind didn't spot.