Home > Backend Development > PHP Tutorial > PHP code protection--detailed explanation of the use of Zend Guard_PHP tutorial

PHP code protection--detailed explanation of the use of Zend Guard_PHP tutorial

WBOY
Release: 2016-07-21 15:09:40
Original
1385 people have browsed it

The function of Zend Guard is to use compilation processing to protect PHP source code from decompilation and viewing, unauthorized custom modifications, unauthorized use and redistribution, etc. Moreover, it was developed by Zend, the owner of PHP, and is a patron saint completely tailored for PHP.
Now, please join me in learning to use Zend Guard to encrypt and protect our PHP source code.
 
Practical: Encrypted PHP source code
Download: http://www.zend.com/en/products/guard/
Next let’s prepare a simple The PHP program test.php is used to test whether it can be protected by Zend Guard. The code of test.php is as follows:

Copy code The code is as follows:

phpinfo();
?>

Open Zend Guard, click from the File menu to create a new project, as shown in Figure 1. Click Next to enter the directory and file addition interface. Since we are only testing one file, click Add File to add test.php, and then click Finish to generate the project.
 
At this time, Zend Guard will automatically open the newly created project, list the files in the project on the left side of the interface, and list relevant information about the project on the right side. Now, we can compile the source code. Click Encode in the Links on the right. The Console window at the bottom of the interface displays "The operation has completed successfully.", which means that the compilation has been completed.
Now go to the directory where the encrypted file is saved, and you will see that there is also a test.php in it. Is it the same as the original test.php? Open it with editing software, and you can see that it is no longer the original content, as shown in Figure 2. Note: You must save the original code, otherwise it will be lost and you will not be able to view and modify it.
 
Next, test the encrypted code and access the encrypted PHP program from the browser. Oops, something went wrong and it cannot run, and the information shown in Figure 3 is displayed. It turns out that PHP programs encrypted using Zend Guard need a partner - Zend Optimizer to execute normally and improve efficiency. It can be downloaded and installed from http://www.zend.com/en/products/guard/. During the installation process, the "Choose the php.ini folder" step means setting the location of the PHP configuration file php.ini on the system, and the "Choose the Web server's root folder" step means setting the location of the Web server software. After the installation is complete, open php.ini with Notepad. At the end we will see configuration information similar to the following:
[Zend]
zend_extension_manager.optimizer_ts="E:Program FilesZendZendOptimizer-3.3.0libOptimizer-3.3.0 "
zend_extension_ts="E:Program FilesZendZendOptimizer-3.3.0libZendExtensionManager.dll"
This means that Zend Optimizer has been installed successfully. We can restart the web server software to make Zend Optimizer take effect. Note: If the server you are using has already been installed or contains Zend Optimizer, you do not need to install it again.
Now try to access the encrypted PHP program from the browser again. Sure enough, it can run normally. From the displayed information, we can see the information of Zend Optimizer
Parsing Zend Guard encryption Principle
Let us look at the process so that we can understand the protection principle of Zend Guard at a glance. Compile the PHP source code into encrypted code through Zend Guard, and then execute it through PHP loaded with Zend Optimizer. The program distributed to others is encrypted code and can be executed, but without the source code, others cannot view and modify it. Therefore, we can add appropriate code to the program to detect the current time of the system to see if it exceeds the preset time limit. If it does, exit the program and prevent continued execution.

The working principle of Zend Guard is similar to Java. The compiled PHP program is like the compiled Java binary code and requires the support of JVM to run. Zend Optimizer can be regarded as a virtual machine of PHP. Zend Guard and Zend Optimizer work together to complete the work of compiling encryption and executing compiled code.

License management is a deeper use and can be used to generate license files to limit the use of the program by selecting different license modes, such as the number of simultaneous users, time limits, and network segmentation Or a specific server, etc. Interested readers can check the help file provided by Zend Guard itself to learn the specific usage.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/327264.htmlTechArticleThe function of Zend Guard is to use compilation processing to protect PHP source code from being decompiled and viewed. Authorized custom modifications, unauthorized use and republication, etc. And, it...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template