When this function is called the first time, it will return a hash value based on a part of the current timestamp.
function getAccessKey(){
$code = '';
$curTime = time();
$code = md5(substr($curTime,0,7));
return $code;
}
The value returned will change sometime between 1 and 1000 seconds relative to the first time it is called.
I don't know if this is possible, but I am looking for a way to control the time interval at which the string value changes, WITHOUT storing the timestamp of the original function call. For example, I would like to invalidate the access key (change the string) 90 seconds from the time of the original call. Has anyone used an algorithm that does something like this?
Thanks
Edit: Just to clarify - the above method will be used by 3rd parties as an API call, that will allow them to build a "passwordless login" link. I do not want them to have to store any data or make any secondary API calls to use this. I just want the returned access key code to work for 90 seconds from the time it is requested, and then fail to work after 90 seconds from the request. I'm not concerned about the type of encryption used at this point, just pondering the ability to invalidate the string after a specific time interval.