Doc #69157 [NEW]: typo
From: zorro_damian at hotmail dot com
Operating system: Irrelevant
PHP version: Irrelevant
Package: Unknown/Other Function
Bug Type: Documentation Problem
Bug description:typo
Description:
------------
Wrong example script at
http://php.net/manual/en/function.crypt.php
=> 'Example #1 crypt()
examples'.
WRONG:
if (hash_equals($hashed_password, crypt($user_input, $hashed_password))
{
echo "Password verified!";
}
GOOD:
if (hash_equals($hashed_password, crypt($user_input, $hashed_password)))
{
echo "Password verified!";
^
} This
fixes it.
The example script closes the: crypt(), hash_equals(), but not the if().
Test script:
---------------
<?php
$hashed_password = crypt('mypassword');
/* You should pass the entire results of crypt() as the salt for
comparing a
password, to avoid problems when different hashing algorithms are
used. (As
it says above, standard DES-based password hashing uses a 2-character
salt,
but MD5-based hashing uses 12.) */
if (hash_equals($hashed_password, crypt($user_input, $hashed_password)))
{
echo "Password verified!";
}
?>
Expected result:
----------------
Irrelevant
Actual result:
--------------
Irrelevant
--
Edit bug report at https://bugs.php.net/bug.php?id=69157&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=69157&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=69157&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=69157&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=69157&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=69157&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=69157&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=69157&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=69157&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=69157&r=support
Expected behavior: https://bugs.php.net/fix.php?id=69157&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=69157&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=69157&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=69157&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=69157&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=69157&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=69157&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=69157&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=69157&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=69157&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=69157&r=mysqlcfg
Thread (3 messages)
- zorro_damian at hotmail dot com