note 32258 added to function.md5
| From: | paj at pajhome dot org dot uk | Date: | Wed, 21 May 2003 20:20:10 +0000 |
| Subject: | note 32258 added to function.md5 | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-48778@lists.php.net to get a copy of this message | ||
Hi,
You can use the MD5 function in combination with a similar JavaScript function to protect user
passwords for logins. The arrangement goes like this:
When the user requests the login page, the server generates a random number. It stores this in a
session variable as well as sending to the client.
When the user clicks submit, JavaScript in the client computes md5(password + random).
The server can also generate this hash, because it already knows the password and random number. It
uses this to check that the user entered the correct password.
The password has not been transmitted in the clear, and next login the random number will be
different, so an attacker can't use a "replay attack".
JavaScript MD5 is available here: http://pajhome.org.uk/crypt/md5/
Paul
----
Manual Page -- http://www.php.net/manual/en/function.md5.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+32258
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+32258&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+32258&report=yes