PHP Classes
elePHPant
Icontem

PHP Obfuscator Code: Obfuscate PHP code using base64 and compression

Recommend this page to a friend!
  Info   View files Documentation   View files View files (3)   DownloadInstall with Composer Download .zip   Reputation   Support forum (2)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2017-10-27 (1 month ago) RSS 2.0 feedNot enough user ratingsTotal: 257 This week: 2All time: 7,503 This week: 357Up
Version License PHP version Categories
obfuscator-php-class 1.2Freely Distributable5PHP 5, Text processing, Code Generation
Description Author

This class can obfuscate PHP code using base64 and compression.

It takes a given string of PHP code and generates another code obfuscating the input code.

When running the obfuscated code, it is equivalent to run the original code.

Name: Pierre-Henry Soria <contact>
Classes: 13 packages by
Country: United Kingdom United Kingdom
Age: 27
All time rank: 67131 in United Kingdom United Kingdom
Week rank: 62 Up3 in United Kingdom United Kingdom Up

Details

PHP Obfuscator

Simple and effective Obfuscator PHP class (this is not a stupid base64 encoding script, but a real and effective obfuscation script)

Overview

If you want to keep your open source code private, but working on all Web hosting. This Obfuscator class is the obfuscator you need!

Not easy readable by developers (unless they are ready to spend lot of time). This will really discourage them :smiley:

Usage

Example 1

<?php
require 'Obfuscator.class.php';

$sData = <<<'DATA'
    echo 'This is my PHP code, can be class class, interface, trait,... in PHP 5, 7, 7.2, ..., etc.';
DATA;

$sObfusationData = new Obfuscator($sData, 'Class/Code NAME');
file_put_contents('my_obfuscated_data.php', '<?php ' . "\r\n" . $sObfusationData);

Example 2

<?php
require 'Obfuscator.class.php';

$sData = <<<'DATA'
    $hour = date('H');

    echo 'The hour (of the server) is ' . date('H:m');
    echo ', and will give the following message:<br><br>';

    if ($hour < 10) {
        echo 'Have a good morning!';
    } elseif ($hour < 20) {
        echo 'Have a good day!';
    } else {
        echo 'Have a good night! zZz z';
    }
DATA;

$sObfusationData = new Obfuscator($sData, 'Give a name to the piece of code you want to obfuscate');
file_put_contents('obfuscated_code.php', '<?php ' . "\r\n" . $sObfusationData);

Run obfuscated_code.php file and you will see something like below:

The hour (of the server) is 19, and will give the following message: Have a good day!

Requirement

  • PHP 5.2 or higher (works with PHP 7.*+ as well!)

History

I first created it for my needs, especially for the license file of my pH7CMS Software in early 2014 but now (summer 2016), I don't need to keep this project private and want to share it for the others (hoping it will help you and saving time!).

I did change anything since the first version and didn't review it, so could be improved. Feel free to add your improvements by forking it and create a new PR. It will be a pleasure for me to see your contribution!

FYI, in 3 years, I never found my obfuscated code unobfuscated (and one project which is pH7CMS had been downloaded by over 50,000 users) so you can be quite confidend (however as you can understand, I cannot give any guarantee on it).

Who I am?

I'm Pierre-Henry Soria, Software Developer, love learning new things every single day and also passionate about e-businesses and e-marketing.

How Contacting Me?

You can by email at pierrehenrysoria+github [[AT]] gmail [[D0T]] com

The License

The script is under Creative Commons Attribution 3.0 license or later; See the LICENSE.txt file.

  Files folder image Files  
File Role Description
Accessible without login Plain text file LICENSE.txt Lic. License text
Plain text file Obfuscator.class.php Class Class source
Accessible without login Plain text file README.md Doc. Documentation

 Version Control Unique User Downloads Download Rankings  
 100%
Total:257
This week:2
All time:7,503
This week:357Up
User Comments (1)