One Simple Way to Encrypt, Obfuscate, Hide or Protect Your PHP Code

This way is so simple that anyone who’s a beginner in PHP can use it immediately to obfuscate and hide the original PHP code. Generally, it’d make it much harder for someone to find a specific phrase in your code as it’s encrypted, though in a rather simple way using 4 PHP functions: gzinflate(), gzdeflate(), base64_encode() and base64_decode().

For example, you can make it eventually impossible for someone who know nothing about PHP or programming to modify your code and some of your native strings. It comes quite handy in encoding, obfuscating and protecting your credits lines in the footer of your scripts of web software.

Say here is the line of code you want to hide from being modified:

echo "You can't find me!"; // it's "echo" instead of "echo", same below. Have to post them this way because of a WP bug.

You can get the obfuscated and encrypted version of this line of code by:

echo base64_encode(gzdeflate('echo "You can\'t find me!";'));

Which would output:


This is the code you should use in your script. As it’s all encrypted and obfuscated, the original string and code are totally hidden, protecting them from being changed.

To run the hidden code, replace the original line of code with this one:


It’s simply the reverse of the encoding plus an eval() function of PHP. And because all the original code and strings are totally encrypted in obfuscation, it’d be harder for non-programmers to modify your script but not professionals. For absolute protection of your code, use Zend Guard.

3 thoughts on “One Simple Way to Encrypt, Obfuscate, Hide or Protect Your PHP Code”

Comments are closed.

Scroll to Top