<?PHPHeader(' Content-type:text/html;charset=utf-8 ');functionEncode_file_contents ($filename) { $type=Strtolower(substr(STRRCHR($filename, '. '), 1)); if(' php ' = =$type&&Is_file($filename) &&is_writable($filename)){//compressed code if PHP file is writable $contents=file_get_contents($filename);//determine if the file has been encoded $pos=Strpos($contents, ' Powered by Arzn qq:1314778 '); 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, ' <?php '); $footerPos=Strrpos($contents, '?> '); $contents=substr($contents,$headerPos+5,$footerPos-$headerPos); $encode=Base64_encode(gzdeflate($contents));//Start Coding $encode= ' <?php '. " \ n Eval (gzinflate (Base64_decode ("." ").$encode."‘".")));\ N\n?> "; return file_put_contents($filename,$encode); } } return false;}//calling Functions$filename= ' 1.php '; Encode_file_contents ($filename);Echo"OK, encryption done!" "?>
The above is the encryption code
Here is the decryption code
<?PHP$Code= ' Fill in the code to be decrypted here ';//base64 Encoding $File= ' decoded.php ';//files saved after decoding $Temp=Base64_decode($Code); $temp=gzinflate($Temp); $FP=fopen($File, "W"); fwrite($FP,$temp); fclose($FP); Echo"Decryption succeeds!" "; ?>
PHP Base64_decode Decoding method