开发者

gzinflate erroring

开发者 https://www.devze.com 2023-01-02 03:55 出处:网络
Well, I\'m trying to gzdeflate my code to perform some very low level encryption for distribution, to use with eval(gzinflate(\'defla开发者_JAVA技巧ted_code\'));

Well, I'm trying to gzdeflate my code to perform some very low level encryption for distribution, to use with eval(gzinflate('defla开发者_JAVA技巧ted_code'));

However whenever I try to inflate the deflated string, it outputs an error.

For example:

echo(gzdeflate('test')); outputs +I-.�

But when I try to echo(gzinflate('+I-.�')); it only outputs Warning: gzinflate() [function.gzinflate]: data error

Is there something I'm missing? Why is it outputting this error rather than test?


The output of

$s = gzdeflate('test');
for ($i=0; $i<strlen($s); $i++) {
  printf("%02X ", ord($s[$i]));
}

is 2B 49 2D 2E 01 00. The last two bytes 01 00 are in this case the tricky part.
You used echo to print the result "string". What was the output medium?
When I copy the string +I-.� via ultraedit into the script the output is 2B 49 2D 2E 3F. A different result and the cause for gzinflate() to bail out.

If you really have to display the data in a medium that cannot show all possible "characters" in the result of gzdeflate() you have to encode the result in a way that either those unprintable characters are avoided or encoded in a suitable form for that medium, e.g. via base64_encode().

0

精彩评论

暂无评论...
验证码 换一张
取 消