Skip to content

Instantly share code, notes, and snippets.

@Cvar1984
Created April 28, 2020 12:11
Show Gist options
  • Select an option

  • Save Cvar1984/95b2b9332f38fa19c484561caea8be0b to your computer and use it in GitHub Desktop.

Select an option

Save Cvar1984/95b2b9332f38fa19c484561caea8be0b to your computer and use it in GitHub Desktop.
Php quick encode file
<?php
/**
* Copyright (c) 2020 Ramdhan Firmansyah
* File : encode.php
* @author : Cvar1984 <[email protected]>
* Date : 28.04.2020
* Last Modified Date: 28.04.2020
* Last Modified By : Cvar1984 <[email protected]>
*/
while (!file_exists($fileName)) {
$fileName = readline('File Name : ');
$fileName = trim($fileName);
}
$outputName = readline('Output Name : ');
$outputName = trim($outputName);
$fileContents = file_get_contents($fileName);
$fileContents = base64_encode(gzdeflate($fileContents));
$fileContents = '<?php eval(\'?>\' . gzinflate(base64_decode(\'' . $fileContents . '\')));';
if (file_put_contents($outputName, $fileContents)) {
echo 'Original Size : ' . filesize($fileName) . ' Bytes' . PHP_EOL;
echo 'Encoded Size : ' . filesize($outputName) . ' Bytes' . PHP_EOL;
} else {
echo 'Can\'t write output permission denied' . PHP_EOL;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment