How to Protect Your PHP Source Code

October 8th, 2012 by Laeeq | 2 comments

One of the main threat PHP developers face is that PHP is an interpreted language, means PHP source code is readable by anybody who downloads your application. We can say that it’s a drawback of PHP. But you can protect your intellectual property by encoding your PHP source code. Here in this article I will explain how to protect your PHP source code.

Actually there are many tools available for protecting php code. But here we will discuss ionCude PHP encoder tool. By this tool, you can protect your PHP 4 & 5 source code from easy observation, theft and change. So before releasing your PHP software, you can use the encoder to convert your plain-text PHP files into special encrypted files.

The ionCude PHP Encoder is available for Windows, Linux, FreeBSD and Intel OS X. All versions offer command line access for encoding, and also for creating license files using Pro or Cerberus. This feature is ideal if you wish to automate processing. The Windows Encoder also includes an easy to use GUI, and the Windows Pro and Cerberus editions include a Linux based license generator for PHP scripts too, allowing scripts to be protected using Windows and creating license files from a Linux based web server.

How To Encode PHP source files

Here we will run a php script(phpencoder.php) for encoding its source code.  We will use below command to encode this file.

/usr/local/ioncube/ioncube_encoder5 phpencoder.php -o phpencoder-enc.php

  1. <?php
  2. echo “MY PHP Encoder Example!”;
  3. ?>

You can also Encode an entire project directory by using below command:

/usr/local/ioncube/ioncube_encoder5 projectDir -o build

As There are are many different options available, encoding above script (phpencoder.php) with the default options will return following PHP file.

  1. <?php
  2. echo(‘Site error: the file <b>’.__FILE__.‘</b> requires the ionCube PHP Loader ’.
  3. basename($__ln).‘ to be installed by the site administrator.’);
  4. ?>
  5. 4+oV5BgRgd22U2z7JoK/KmKPIcszhD8pg3hvN+5vc4HFcsGMn/El/4CMYaLFFzaqguLCeb9su8xn
  6. i0+eWxJg/kwNHRkiBvY1aMf1AvwPf14DIwCvegtJC7cbx9cN5jBjwSspVjhVsQnxFx9oBut6R0Kc
  7. V+OLw6XBTNm5sKpbL6DVm2jqk8Wasm9oJgKLZxBtvVBeP5vZrOiod+L7SoplcmTgtyr5wzS3sEzj
  8. r7ixXPUY4H82MyuzZyjYTkSKkz9qlMzWHddrUHJX3y0zPfDqWDUeD1BibJQJ9BXkP7jb4pdKQv/h
  9. sMqhthNQQRSp6nOJHq8oDDYLE+p403GYs2As9qEI2wNAg6j6ln0BRP7shcbNTb5a8O4VjjLhGDwG
  10. 1AYOxaM4R5QneCFr+xYdtEYSep8FW1i9IBzF1FuDa7eMoPDqaQdjTLAPsy5O831yGpAHohx3FzUK
  11. aewZTV+tdru=

The ionCube PHP Encoder is a commercial product, there is a limited time Trial Version available for download.

You can subscribe to PHPZAG.COM posts by Email

 

Related Topics:

  • Wrapping Text using PHP
  • PHP 5.5 beta 4 is now available
  • Swapping Array Keys and Values
  • PHP Security
  • Working with Image Metadata in PHP
  • Converting Between Relative and Absolute File Path
  • Parsing File Paths with PHP
  • How to remove HTML Comments with PHP?
  • How to access .htaccess values?
  • Dealing With Common PHP Errors
  • Interview Questions and Answers for Freshers
  • Display numbers with ordinal suffix using PHP
  • Function to set COLLATION on database fields of Mysql
  • Read and write to remote files using PHP
  • Sharing PHP SESSION Variables between Multiple Subdomains
  • PHP 5.5.0 Alpha4 Development Preview Released
  • Check a string starts with http using PHP
  • Cross-Site Scripting Attacks (XSS)
  • PHP 5.4.11 and PHP 5.3.21 released!
  • PHP Memory Leak Issue
  •  

     

    1. October 9th, 2012 at 18:19 | #1

      The problem with ioncube is that the users of your code will run into issues especially if their environment doesn’t have ioncube installed.

      Additionally, if someone wants to make a good-faith modification to your code (e.g. fix a bug) then they have to call you. What will happen if you – all of a sudden – decide to stop programming?

    2. December 1st, 2012 at 07:38 | #2

      Whenever there is an option to encrypt the code, also there is possibility for decrypting it.

    1. No trackbacks yet.