Obfuscating php codes

Sometimes we may want to obfuscate our php scripts so that it 's no longer human-readable. We can use trasher class freely downloaded from phpclasses.org or you can download here (3kb including example files).

Below is the example of how to use it (before and after obfuscated):

test.php (script which will be confuscated)
<?php
$x = 5;
$y = 10;
$z = $x * $y;
echo ("X * Y = $z");
 ?>

sample.php (script which will confuscate test.php)
<?php 
// include the phptrasher class
require_once('phptrasher.class.php');
// create a new object 
$phptrasher = new phptrasher();
// initialize the class
$phptrasher->initialize();
// setup the class
$phptrasher->removecomments = true;
$phptrasher->removelinebreaks = true;
$phptrasher->obfuscateclass = true;
$phptrasher->obfuscatefunction = true;
$phptrasher->obfuscatevariable = true;
// get the obfuscated code
$obfuscated = $phptrasher->trash('test.php');
// print the formatted code in a beautiful way
highlight_string($obfuscated);
?>

run sample.php to get obfuscated codes of test.php

test1.php (after confuscated)
<?php $_ccc819a68916c3ef4fd822abb9366846 = 5; $_9870ddd74d75773009cf509800565c6f = 10; $_b7739f51732251c6470ac18757649a94 = $_ccc819a68916c3ef4fd822abb9366846 * $_9870ddd74d75773009cf509800565c6f; echo ("X * Y = $_b7739f51732251c6470ac18757649a94"); ?>


No comments: