Well, I’m trying to gzdeflate my code to perform some very low level encryption for distribution, to use with eval(gzinflate('deflated_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
is
2B 49 2D 2E 01 00. The last two bytes 01 00 are in this case the tricky part.You used
echoto print the result “string”. What was the output medium?When I copy the string
+I-.�via ultraedit into the script the output is2B 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().