Skip to content

Instantly share code, notes, and snippets.

@ivan1911
Created April 10, 2013 08:37
Show Gist options
  • Save ivan1911/5352891 to your computer and use it in GitHub Desktop.
Save ivan1911/5352891 to your computer and use it in GitHub Desktop.
Simple php obfuscator
<?php
$infile=$_SERVER['argv'][1];
$outfile=$_SERVER['argv'][2];if (!$infile || !$outfile) {
    die("Usage: php {$_SERVER['argv'][0]} <input file> <output file>\n");}
echo "Processing $infile to $outfile\n";
$data="ob_end_clean();?>";
$data.=php_strip_whitespace($infile);
// compress data
$data=gzcompress($data,9);
// encode in base64
$data=base64_encode($data);
// generate output text
$out='<?ob_start();$a=\''.$data.'\';eval(gzuncompress(base64_decode($a)));$v=ob_get_contents();ob_end_clean();?>';
// write output text
file_put_contents($outfile,$out);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment