[Phpmyadmin-devel] PMA_blowfish_encrypt() and full_str_pad() instead of str_pad()?

Hi, what is the difference between PHP:str_pad() and phpMyAdmin:full_str_pad()? used in PMA_blowfish_encrypt() -- Sebastian Mendel www.sebastianmendel.de

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." http://terra.di.fct.unl.pt/docs/php/function.str-pad.php.htm ------ So it look like there were (are ?) limits to what we can feed to str_pad() as the pad string. In our case, however, we are using a null "\0" as the padding character; I tested it and it works in PHP 5.2.2 but I can't test right now with PHP 4. There is still a problem when you use str_pad() to pad with a string like echo str_pad('abc',100," ",1); the result ends with the "&" character.

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 simplest testcase is $string = 'string'; $pad = '\0'; echo (strlen($string . $pad) === strlen(str_pad($string, strlen($string) + 1, $pad))); -- Sebastian Mendel www.sebastianmendel.de

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.
participants (2)
-
Marc Delisle
-
Sebastian Mendel