note 42831 added to function.md5

From: Date: Mon, 31 May 2004 12:09:24 +0000
Subject: note 42831 added to function.md5
Groups: php.notes 
Request: Send a blank email to php-notes+get-70340@lists.php.net to get a copy of this message
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. ---- Manual Page -- http://www.php.net/manual/en/function.md5.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+42831 Delete -- http://master.php.net/manage/user-notes.php?action=delete+42831&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+42831&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#70340) next »