note 42831 deleted from function.md5 by tomsommer
| From: | tomsommer@php.net | Date: | Thu, 17 Jun 2004 18:35:35 +0000 |
| Subject: | note 42831 deleted from function.md5 by tomsommer | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-71241@lists.php.net to get a copy of this message | ||
Note Submitter: echorunner@hotmail.com
----
Just a thought on having MD5 hashes which can expire:
I read somewhere to create a hash that expires at 12AM daily is to add the current date to the
clear-text and then hash it.
Another method (although the nature of its security is unknown) is to actually create a cookie
(setcookie) with an expiry date (10 minutes) containing a random string (uniqid) and then hash BOTH
the random string and date together with the clear-text.
//this sets the cookie, bear in mind - the page requires a refresh before the cookie becomes visible
to the script
$MD5EXPIRYID=uniqid("MD5");
setcookie("MD5EXPIRY",$MD5EXPIRYID, time()+600);
Next when you generate the hash, add $MD5EXPIRYID to the hash along with the date:
//creates the hash
$hash=md5($cleartext.mktime("Y m d").$MD5EXPIRYID);
This should create a hash that expires in 10 minutes or at 12AM on the same day, whichever comes
first.