PHP code protection-detailed instructions on ZendGuard

Source: Internet
Author: User
This article provides a detailed analysis of the use of zendguard. For more information, see the role of Zend Guard, it is to protect PHP source code from decompiled viewing, unauthorized custom modification, unauthorized use and re-release by means of compilation and processing. In addition, it is developed by PHP's Zend company and is a completely customized protector for PHP.
Next, please join me to learn how to use Zend Guard to encrypt and protect our PHP source code.
  
Practice: encrypt PHP source code
Download: http://www.zend.com/en/products/guard/
Next, let's prepare a simple PHP program test. php to test whether it can be protected by Zend Guard. The code for test. php is as follows:
The code is as follows:
Phpinfo ();
?>

Open Zend Guard and click "File" to create a new project, as shown in Figure 1. Click Next to go to the directory and File adding interface. because we only test a File, click Add File to Add test. php. then click Finish to generate the project.
  
At this time, Zend Guard will automatically open the new project, list the files in the project on the left side of the interface, and list the project information on the right side. Now we can compile the source code. Click Encode (compile) in The link on The right. The "The operation has completed successfully." is displayed in The Console window at The bottom of The interface, indicating that The compilation is completed.
Now, in the directory saved in the encrypted file, we can see that there is also a test. php. Is it the same as the original test. php? Open it with the editing software and you can see that it is no longer the original content, as shown in 2. Note: you must save the original code. Otherwise, you will be lost and cannot view or modify the code yourself.
  
Next, test the encrypted code and access the encrypted PHP program from the browser. oh, an error occurred. the code cannot run and the information shown in 3 is displayed. Originally, the PHP program encrypted with Zend Guard still needs a partner-Zend Optimizer to run normally and improve efficiency. You can download and install the SDK from http://www.zend.com/en/products/guard. During installation, "Choose the php. ini folder "indicates setting the PHP configuration file on the system. ini location. the "Choose the Web server's root folder" step indicates setting the location of the Web server software. After the installation is complete, use notepad to open php. ini. at the end, we will see the following configuration information:
[Zend]
Zend_extension_manager.optimizer_ts = "E: \ Program Files \ Zend \ ZendOptimizer-3.3.0 \ lib \ Optimizer-3.3.0"
Zend_extension_ts = "E: \ Program Files \ Zend \ ZendOptimizer-3.3.0 \ lib \ ZendExtensionManager. dll"
This indicates that Zend Optimizer has been successfully installed. we can restart the Web server software to make Zend Optimizer take effect. Note: If the used server has been installed or contains Zend Optimizer, you do not need to install it again.
Now try accessing the encrypted PHP program from the browser again, and it will run normally. from the displayed information, we can see the Zend Optimizer information.
Parsing Zend Guard encryption principles
Let's take a look at the process to get a clear picture of Zend Guard's protection principles. Use Zend Guard to compile the PHP source code as the encryption code, and then run it by loading the Zend Optimizer PHP. The program that is distributed to others is the encrypted code that can be executed, but without the source code, others cannot view and modify it. Therefore, we can add appropriate code in the program to check the current time of the system to see if the preset time limit has been exceeded. if the time limit has been exceeded, exit the program to prevent execution.

Zend Guard works in a similar way to Java. the compiled PHP program is like a compiled Java binary code and can be run only with JVM support. Zend Optimizer can be viewed as a PHP virtual machine. Zend Guard works with Zend Optimizer to complete compilation encryption and code execution after compilation.

License Management is a more in-depth use, which can be used to generate License files, so as to restrict the use of programs by selecting different licensing modes, for example, the number of simultaneous users, time restrictions, network segments, or specific servers. If you are interested, you can view the help files provided by Zend Guard to understand the specific usage.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.