search
Homephp教程php手册PHP-Beast 加密你的PHP源代码

PHP-Beast 加密你的PHP源代码

Jun 06, 2016 pm 08:10 PM
phpencryptionsource codeTalk about itfirst

首先说说为什么要用PHP-Beast? 有时候我们的代码会放到代理商上, 所以很有可能代码被盗取,或者我们写了一个商业系统而且不希望代码开源,所以这时候就需要加密我们的代码。 另外PHP-Beast是完全免费和开源的, 当其不能完成满足你的需求时, 可以修改其代码

首先说说为什么要用PHP-Beast?
有时候我们的代码会放到代理商上, 所以很有可能代码被盗取,或者我们写了一个商业系统而且不希望代码开源,所以这时候就需要加密我们的代码。
另外PHP-Beast是完全免费和开源的, 当其不能完成满足你的需求时, 可以修改其代码而满足你的要求。

1. 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

注意:在编译扩展之前先修改加密的key,如下图。

143433_T6LJ_119031

编译好之后修改php.ini配置文件,加入配置项:extension=beast.so,重启php-fpm。

安装完成后可以在phpinfo中看到如下结果:

143013_2WTq_1190312. 安装好PHP-Beast模块后,可以使用工具包中的encrypt_project.php工具来加密你的项目,你只需要输入项目的路径和输出的项目路径即可(这个工具只会加密PHP文件,其他文件只会简单的复制),如:

143102_2ZJz_119031加密完成后使用文本编辑器看编译后的文件可以发现已经变为乱码,如:

143126_o1mC_119031

3. 当然你可能不希望加密项目的所有PHP源文件,所以你可以使用PHP-Beast模块提供的beast_encode_file()函数来加密其中的某个 文件,使用方法:beast_encode_file($input_file, $output_file),$input_file是要加密的文件,$output_file是要输出加密后的文件。

4. 把源码加密后就可以放到服务器上运行了。另外PHP-Beast模块提供缓存功能,我们可以在php.ini文件中修改缓存的大小来控制PHP-Beast模块可以使用的缓存。如:

[beast]
beast.cache_size = 20000

我们可以使用beast_cache_status()函数来查看缓存的状态。

最新的PHP-Beast 0.6主要修改了一些bug和增加了一些配置项:

1. 设置缓存大小可以使用单位, 例如: beast.cache_size = 10m;

2. 可以在配置文件中禁止beast模块, 例如: beast.enable = Off;

3. 增加了日志记录功能, 可以使用beast.log_file配置项指定日志文件.

4. 使用文件锁解决原来信号量锁导致的bug, 可以使用beast.lock_path来指定锁路径.

无觅相关文章插件,快速提升流量

Statement
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools