|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2009-10-22 11:51 UTC] rgr at woodwing dot com
Description:
------------
The function Crypt() does not work with less than 4 characters in PHP 5.3.0. See the code sample below.
When using 'test' as $user_input and $password it does work correct.
Reproduce code:
---------------
---
From manual page: function.crypt#Examples
---
$user_input = 'tes';
$password = crypt('tes'); // let the salt be automatically generated
if (crypt($user_input, $password) == $password) {
echo "Password verified!";
}
Expected result:
----------------
The comparison should result true.
Actual result:
--------------
The comparison returns false.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 17:00:01 2025 UTC |
Hi, right now I cannot test it with PHP 5.3.8 Here is my test. Source code: <?php phpinfo(INFO_GENERAL); $user_input = 'tes'; $password = crypt($user_input); if (crypt($user_input, $password) == $password) { echo "Password verified!"; } else { echo "Password NOT verified!"; } echo "<br>"; $user_input = 'test'; $password = crypt($user_input); if (crypt($user_input, $password) == $password) { echo "Password verified!"; } else { echo "Password NOT verified!"; } ?> Here is the output (I've extracted the main information with copy&paste): PHP Version 5.3.6 System Windows NT T11972946 5.2 build 3790 (Windows Server 2003 Enterprise Edition Service Pack 2) i586 Build Date Mar 17 2011 10:46:06 Compiler MSVC9 (Visual C++ 2008) Architecture x86 Configure Command cscript /nologo configure.js "--enable-snapshot-build" "--enable-debug-pack" "--disable-zts" "--disable-isapi" "--disable-nsapi" "--without-mssql" "--without-pdo-mssql" "--without-pi3web" "--with-pdo-oci=D:\php-sdk\oracle\instantclient10\sdk,shared" "--with-oci8=D:\php-sdk\oracle\instantclient10\sdk,shared" "--with-oci8-11g=D:\php-sdk\oracle\instantclient11\sdk,shared" "--with-enchant=shared" "--enable-object-out-dir=../obj/" "--enable-com-dotnet" "--with-mcrypt=static" Server API CGI/FastCGI Virtual Directory Support disabled Configuration File (php.ini) Path C:\WINDOWS Loaded Configuration File C:\Program Files\PHP\php.ini Scan this dir for additional .ini files (none) Additional .ini files parsed (none) PHP API 20090626 PHP Extension 20090626 Zend Extension 220090626 Zend Extension Build API220090626,NTS,VC9 PHP Extension Build API20090626,NTS,VC9 Debug Build no Thread Safety disabled Zend Memory Manager enabled Zend Multibyte Support disabled IPv6 Support enabled Registered PHP Streams php, file, glob, data, http, ftp, zip, compress.zlib, compress.bzip2, https, ftps, phar Registered Stream Socket Transports tcp, udp, ssl, sslv3, sslv2, tls Registered Stream Filters convert.iconv.*, mcrypt.*, mdecrypt.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, dechunk, zlib.*, bzip2.* Password NOT verified! Password verified!