First, let's talk about why PHP-Beast is used? Sometimes our code is put on the agent, so it is very likely that the code is stolen, or we have written a commercial system and do not want the code to be open-source, so at this time we need to encrypt our code. In addition, PHP-Beast is completely free and open-source. When it cannot meet your needs, you can modify its code.
First, let's talk about why PHP-Beast is used? Sometimes our code is put on the agent, so it is very likely that the code is stolen, or we have written a commercial system and do not want the code to be open-source, so at this time we need to encrypt our code. In addition, PHP-Beast is completely free and open-source. When it cannot meet your needs, you can modify its code.
First, let's talk about why PHP-Beast is used?
Sometimes our code is put on the agent, so it is very likely that the code is stolen, or we have written a commercial system and do not want the code to be open-source, so at this time we need to encrypt our code.
In addition, PHP-Beast is completely free and open-source. When it cannot meet your needs, you can modify its code to meet your requirements.
1. install PHP-Beast
$ wget https://github.com/liexusong/php-beast/archive/master.zip$ unzip master.zip$ cd php-beast-master$ phpize$ ./configure$ make$ sudo make install
Note: Modify the encrypted key before compiling the extension, for example.
After compilation, modify the php. ini configuration file, add the configuration item extension = beast. so, and restart php-fpm.
After the installation is complete, you can see the following results in phpinfo:
2. after installing the PHP-Beast module, you can use the encrypt_project.php tool in the toolkit to encrypt your project, you only need to enter the project path and the output project path (this tool only encrypts the PHP file, and other files are simply copied), such:
After encryption, you can use the text editor to view the compiled files and find that the files have changed to garbled characters, such:
3. of course, you may not want to encrypt all the PHP source files of the project, so you can use the beast_encode_file () function provided by the PHP-Beast module to encrypt a file. Use the following method: beast_encode_file ($ input_file, $ output_file), $ input_file is the file to be encrypted, and $ output_file is the file to be output after encryption.
4. After encrypting the source code, you can run it on the server. In addition, the PHP-Beast module provides the cache function. We can modify the cache size in the php. ini file to control the cache that can be used by the PHP-Beast module. For example:
[beast]beast.cache_size = 20000
You can use the beast_cache_status () function to view the cache status.
The latest PHP-Beast 0.6 mainly modifies some bugs and adds some configuration items:
1. Set the available cache size units, for example, beast. cache_size = 10 m;
2. You can disable the beast module in the configuration file, for example, beast. enable = Off;
3. added the logging function. You can use the beast. log_file configuration item to specify the log file.
4. Use the filelock to solve the bug caused by the original semaphore lock. You can use beast. lock_path to specify the lock path.
Original article address: PHP-Beast encrypts Your PHP source code. Thank you for sharing it with the original author.