简体   繁体   中英

PHP (md5) empty result

I have a problem with this code sample, the result is a blank page. I checked mcrypt_ecb function in php, and is available. Then why I got only empty result?

$suma='9990'; 
$idobj='38'; 
$cislooz='TEST';

$input=$suma.$idobj.$cislooz; 
$key='KEY';

$encrypted_text = mcrypt_ecb(MCRYPT_3DES, $key, substr(sha1($input),0,8), MCRYPT_ENCRYPT,substr(sha1($input),0,8)); 

echo "<b>INPUT: </b>".$input."<br>"; 
echo "<b>KEY: </b>".$key."<br>"; 
echo "<b>Hash sha1: </b>".substr(sha1($input),0,8)."<br>"; 
echo "<b>Hash to 3DES/ECB/NoPadding:</b> ".( $encrypted_text )."<br>"; 
echo "<b>to HEX:</b> ".StrToUpper(bin2hex($encrypted_text))."<hr>"; 

?>

You are probably experiencing a problem somewhere. I tested it on PHP 5.3.0 and it output:

INPUT: 999038TEST
KEY: KEY
Hash sha1: c063a3be
Hash to 3DES/ECB/NoPadding: K\Aj¥íµÉ
to HEX: 4B5C416AA5EDB5C9

You may have a PHP error triggered but the only way to know that is to set:

error_reporting(E_ALL);
ini_set('display_errors',1);

At the top of your script so that you'll be able to see what the error is.

Another explain is that you started an output buffer with ob_start() and you might be managing it wrong.

Or you could have an exit; or die(); somewhere.

As you can see there might be a lot of "because" for your question.

Edit : Finally, at last we discovered the real problem. The spaces in his code where converted to the wrong invisible character; that's because it was copied from a PDF.

没有描述

Here you can see: the first lines works fine and the space correspond to . in the script. The other symbol instead (of the commented green lines) was causing the problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM