Base64+gzinflate compressed encoded (encrypted) files are usually
compression encoding (encryption) code:
Copy CodeThe code is as follows:
function Encode_file_contents ($filename) {
$type =strtolower (substr (STRRCHR ($filename, '. '), 1));
if (' php ' = = $type && is_file ($filename) && is_writable ($filename)) {//If it is a PHP file and can be written with compression encoding
$contents = file_get_contents ($filename);//Determine if the file has been encoded
$pos = Strpos ($contents, '/*protected by grass name http://www.crazyi.cn cryptation*/');
if (false = = = $pos | | $pos >100) {//Remove PHP file comments and whitespace, reduce file size
$contents = Php_strip_whitespace ($filename);
Remove PHP header and tail markings
$headerPos = Strpos ($contents, ' $footerPos = Strrpos ($contents, '?> ');
$contents = substr ($contents, $headerPos +5, $footerPos-$headerPos);
$encode = Base64_encode (Gzdeflate ($contents));//Start coding
$encode = ' ";
Return file_put_contents ($filename, $encode);
}
}
return false;
}
Calling functions
$filename = ' g:\ My Documents \ Desktop \test.php ';
Encode_file_contents ($filename);
?>
function Encode_file_contents ($filename) {
$type =strtolower (substr (STRRCHR ($filename, '. '), 1));
if (' php ' = = $type && is_file ($filename) && is_writable ($filename)) {//If it is a PHP file and can be written with compression encoding
$contents = file_get_contents ($filename);//Determine if the file has been encoded
$pos = Strpos ($contents, '/*protected by grass name http://www.crazyi.cn cryptation*/');
if (false = = = $pos | | $pos >100) {//Remove PHP file comments and whitespace, reduce file size
$contents = Php_strip_whitespace ($filename);
Remove PHP header and tail markings
$headerPos = Strpos ($contents, ' $footerPos = Strrpos ($contents, '?> ');
$contents = substr ($contents, $headerPos +5, $footerPos-$headerPos);
$encode = Base64_encode (Gzdeflate ($contents));//Start coding
$encode = ' ";
Return file_put_contents ($filename, $encode);
}
}
return false;
}
Calling functions
$filename = ' g:\ My Documents \ Desktop \test.php ';
Encode_file_contents ($filename);
?>
compression decoding (decryption) code:
Copy CodeThe code is as follows:
$Code = ' Fill in the code to be decrypted here '; Base64 encoding
$File = ' test.php ';//files saved after decoding
$Temp = Base64_decode ($Code);
$temp = Gzinflate ($Temp);
$FP = fopen ($File, "w");
Fwrite ($FP, $temp);
Fclose ($FP);
echo "Decryption succeeded! ";
?>
http://www.bkjia.com/PHPjc/319481.html www.bkjia.com true http://www.bkjia.com/PHPjc/319481.html techarticle base64+gzinflate Compressed (encrypted) files are usually in the. Eval (Gzinflate (Base64_decode) (a php file for the header. The following we give the relevant encoding decoding (encryption and decryption) ...