I need to give access to a specific page of a website to un-registered visitors, when the admin sends a link with token (like we often see for account activation or password renewal).
Obviously, token needs to be unique as the token itself will dictate what is visible to the visitor (token will be stored in MySQL DB with access given, status, expiry, etc...)
This is what I have, mashed up together from multiple sources:
$key = '#}~*$/"$?&*(."*/[!%]/${"/}';
$unique = uniqid();
$token = $unique.substr(hash('sha512',$unique.$key.microtime()), 0, 19);
It results in a 32 characters string, with the first 13 that can be reverse to get the time created and the last 19 for adding uniqueness.
Is this unique/secure enough.?
Is 32 long enough for an URL token.?