note 66239 added to function.sha1
| From: | erling dot westenvik at gmail dot com | Date: | Wed, 17 May 2006 13:15:24 +0000 |
| Subject: | note 66239 added to function.sha1 | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-111496@lists.php.net to get a copy of this message | ||
Regarding php at REMOVEMEkennel17 dot co dot uk's note below:
The phrase: "To get the correct behaviour", would perhaps be better off if it read:
"To get the wanted (but not recommended) behaviour".
Always honor the expected data types for functions: sha1 expects a string as input, and returns a
string on exit. NULL, TRUE and FALSE are not string data types. The string "" is a string
as good as "any". By following the "logic" that sha1("") should return
"", then what should sha1("a") return? "b"? "c"?
An authentication system that allows for blank passwords is not really an authentication system in
the first place. What you are describing is merely a way to tell the application that you want to
see data in some specific context, like sorted by user name, etc. Create other tools for this
purpose and leave the authentication system to deal with what it is supposed to do: Granting users
access to restricted data and blocking other users from seeing the same data.
Don't store passwords in clear text, but salt and encrypt them. That way it makes perfect sense
having <?php $sStoredPwd === sha1($sStoredSalt . $_POST["sTypedPwd"]); ?>, even with
a blank "password". No other person than the user itself, not even the programmer, should
know the password or be able to guess it. If the user forgets the password, a new one must be
generated.
Regards,
Erling
----
Server IP: 83.137.200.2
Probable Submitter: 193.213.210.66
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.sha1.php
Edit -- http://master.php.net/note/edit/66239
Del: integrated -- http://master.php.net/note/delete/66239/integrated
Del: useless -- http://master.php.net/note/delete/66239/useless
Del: bad code -- http://master.php.net/note/delete/66239/bad+code
Del: spam -- http://master.php.net/note/delete/66239/spam
Del: non-english -- http://master.php.net/note/delete/66239/non-english
Del: in docs -- http://master.php.net/note/delete/66239/in+docs
Del: other reasons-- http://master.php.net/note/delete/66239
Reject -- http://master.php.net/note/reject/66239
Search -- http://master.php.net/manage/user-notes.php