[Phpmyadmin-devel] PMA_blowfish_encrypt() and full_str_pad()

Marc Delisle Marc.Delisle at cegepsherbrooke.qc.ca
Tue May 15 14:54:58 CEST 2007


Sebastian Mendel a écrit :
> Marc Delisle schrieb:
>> Sebastian Mendel a écrit :
>>> Hi,
>>>
>>> what is the difference between PHP:str_pad() and phpMyAdmin:full_str_pad()?
>>>
>>> used in PMA_blowfish_encrypt()
>>>
>> full_str_pad() comes from a comment in the PHP manual for str_pad(). I 
>> realize that on php.net' manual, the comment is no longer intact but see 
>> here the original comment:
>>
>> "In a lot of cases you're better off using str_repeat if you want to use 
>> something like   - it repeats the entire string."
> 
> ok, i understand,
> 
> so it is not really a 'pad' function but more a add string x-times to
> another string function
> 
> the question for us is does str_pad treat '\0' as single char or string ...
> imho it should be a single char and work with str_pad

In PMA_blowfish_encrypt() we are not using '\0' but "\0" so it has to 
treat it as a single char.

> 
> simplest testcase is
> 
> $string = 'string';
> $pad = '\0';
> echo (strlen($string . $pad) === strlen(str_pad($string, strlen($string) +
> 1, $pad)));

Yes and test it under PHP 4.1.0.




More information about the Developers mailing list