|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2009-11-02 09:46 UTC] pajoye@php.net
[2009-11-02 09:59 UTC] pajoye@php.net
[2009-11-02 13:57 UTC] otaviodiniz at gmail dot com
[2009-11-02 20:46 UTC] svn@php.net
[2009-11-02 20:47 UTC] pajoye@php.net
[2011-04-07 12:15 UTC] catalin at aceora dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 06:00:01 2025 UTC |
Description: ------------ The behave of Crypt function on Windows and Linux boxes are different. In the sample function we create a Salt with length of 12 characters. First, the Salt size is incorrect, if i remove one character the Salt, the result will be correct. But with the wrong Salt size the behavior are different: On Windows - The output is incorrect, as it shows the whole Salt without the terminator $... On Linux - PHP strips one character of Salt into it's correct expected size, outputing correctly with the terminator $... Reproduce code: --------------- md5crypt("test"); function md5crypt($password) { $base64_alphabet='ABCDEFGHIJKLMNOPQRSTUVWXYZ' .'abcdefghijklmnopqrstuvwxyz0123456789+/'; $salt='$1$'; for($i=0; $i<9; $i++) { $salt.=$base64_alphabet[rand(0,63)]; } $salt.='$'; echo "<pre>"; echo "Salt: ".$salt."<br />\r\n"; echo "Output: ".crypt($password,$salt); echo "</pre>"; } Expected result: ---------------- Salt: $1$f+uslYF01$ Output: $1$f+uslYF0$orVloNmKSLvOeswusE0bY. //Linux Actual result: -------------- Salt: $1$XcPmtBmRG$ Output: $1$XcPmtBmRGuM82Sm1HMy0I0lX0P3nAd0 //Windows