Home >Backend Development >PHP Tutorial >Encryption method for PHP source code program_PHP tutorial
The article introduces two methods to encrypt the PHP program itself. Our common method is base64_encode(gzdeflate($contents)) to encrypt. The second method is rare and friends in need can also refer to it.
Example 1
The code is as follows
|
Copy code
|
||||
$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, compress it and encode it $contents = file_get_contents($filename); // Determine whether the file has been encoded $contents = php_strip_whitespace($filename); // Remove PHP header and trailer tags $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); |