PHPbase64 + gzinflate compression code and decoding code. Read the PHPbase64 + gzinflate compression code and decoding code. base64 + gzinflate compression encoding (encrypted) files are usually used? Eval (gzinflate (base64_decode (a php file in the header. The encoding and decoding code is given in this article. CODE :? Ph
Base64 + gzinflate compressed (encrypted) files are usually CODE:
Function encode_file_contents ($ filename ){
$ Type = strtolower (substr (strrchr ($ filename, '.'), 1 ));
If ('php' = $ type & is_file ($ filename) & is_writable ($ filename) {// compress the code if the php file is writable.
$ Contents = file_get_contents ($ filename); // checks whether the file has been encoded.
$ Pos = strpos ($ contents, '/* Protected by grass name http://www.crazyi.cnCryptation */');
If (false ===$ pos | $ pos> 100) {// remove php file comments and white spaces to reduce file size
$ Contents = php_strip_whitespace ($ filename );
// Remove the PHP header and tail identifiers
$ HeaderPos = strpos ($ contents ,' $ FooterPos = strrpos ($ contents, '?> ');
$ Contents = substr ($ contents, $ headerPos + 5, $ footerPos-$ headerPos );
$ Encode = base64_encode (gzdeflate ($ contents); // start encoding
$ Encode =' ";
Return file_put_contents ($ filename, $ encode );
}
}
Return false;
}
// Call a function
$ 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) {// compress the code if the php file is writable.
$ Contents = file_get_contents ($ filename); // checks whether the file has been encoded.
$ Pos = strpos ($ contents, '/* Protected by grass name http://www.crazyi.cnCryptation */');
If (false ===$ pos | $ pos> 100) {// remove php file comments and white spaces to reduce file size
$ Contents = php_strip_whitespace ($ filename );
// Remove the PHP header and tail identifiers
$ HeaderPos = strpos ($ contents ,' $ FooterPos = strrpos ($ contents, '?> ');
$ Contents = substr ($ contents, $ headerPos + 5, $ footerPos-$ headerPos );
$ Encode = base64_encode (gzdeflate ($ contents); // start encoding
$ Encode =' ";
Return file_put_contents ($ filename, $ encode );
}
}
Return false;
}
// Call a function
$ Filename = 'G: \ My Documents \ Desktop \ test. php ';
Encode_file_contents ($ filename );
?>
Compression/decoding (decryption) Code:
[Copy this CODE] CODE:
$ Code = 'Enter the decryption encoding here '; // base64 encoding
$ File = 'Test. php'; // decoded File
$ Temp = base64_decode ($ Code );
$ Temp = gzinflate ($ Temp );
$ FP = fopen ($ File, "w ");
Fwrite ($ FP, $ temp );
Fclose ($ FP );
Echo "decrypted! ";
?>