note 59841 added to function.md5
| From: | (anelless_gmail_com) | Date: | Sat, 17 Dec 2005 18:04:33 +0000 |
| Subject: | note 59841 added to function.md5 | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-100340@lists.php.net to get a copy of this message | ||
"mina86 at tlen dot pl"'s (19-Sept-05) HMAC-MD5 implementation is correct but his
example usage provides little practical advantage over the simple concatenation and hash approach to
salting.
$hash = md5($salt . $password);
On the other hand, a good use for a MAC (with a server side private key) would be to store one in
the users cookie in order to verify that cookie's (or parts of them) you issue haven't
been changed manually (or for that matter, by any other website (maybe via a XSS browser exploit?),
MITM attack or evil proxy).
Such a trick allows you to put mildly critical data about a user, that you don't want changed
by anyone but you, in their cookie rather than in your database. This could have advantages
(openness, not needing to store user email addresses at the server side once they have been verified
by email, even do away with the need to store data about a poster in a server side database
altogether but still being able to allow these almost anonymous posters to come along and edit their
submissions with confidence) and be rather entertaining (users trying to crack their cookie code to
elevate their stats and/or permissions).
This is like issueing a passport. The traveller can see all of it, get it stamped (~customise parts
of it) but can also invalidate it and have it revoked. It can also save on expensive and time
consuming nationality/immigration checks (~using the database) at the airport (~the server side).
----
Manual Page -- http://www.php.net/manual/en/function.md5.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+59841
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+59841&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+59841&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+59841&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+59841&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+59841&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+59841&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+59841&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+59841&report=yes
Search -- http://master.php.net/manage/user-notes.php