推薦(免費(fèi)):PHP7
介紹
一個(gè)簡(jiǎn)潔、高性能、跨平臺(tái)的 PHP7 代碼加密擴(kuò)展
源碼地址:GitHub
特點(diǎn)
- 簡(jiǎn)單快速,經(jīng)實(shí)測(cè),幾乎不影響性能
- 兼容 OPcache、Xdebug 等其他擴(kuò)展
- 支持 Linux、macOS、Windows 等系統(tǒng)
- 兼容 Apache、Nginx + PHP-fpm、命令行等運(yùn)行模式
- 加密算法較簡(jiǎn)單,這是出于速度考慮,但仍不易解密
- 若項(xiàng)目的 php 文件很多,可只加密部分重要代碼
- 要求 PHP >= 7.0
安裝
編譯前請(qǐng)?jiān)?core.h
中做如下修改:
/* 這里定制你的加密特征頭,不限長(zhǎng)度,十六進(jìn)制哦 */ const u_char tonyenc_header[] = { 0x66, 0x88, 0xff, 0x4f, 0x68, 0x86, 0x00, 0x56, 0x11, 0x16, 0x16, 0x18, }; /* 這里指定密鑰,設(shè)置長(zhǎng)一些更安全 */ const u_char tonyenc_key[] = { 0x9f, 0x49, 0x52, 0x00, 0x58, 0x9f, 0xff, 0x21, 0x3e, 0xfe, 0xea, 0xfa, 0xa6, 0x33, 0xf3, 0xc6, };
在 Linux、macOS 上編譯
git clone https://github.com/lihancong/tonyenc.git cd tonyenc phpize ./configure make
將編譯好的文件 modules/tonyenc.so 加入到配置項(xiàng) extension=tonyenc.so ,重啟 PHP 服務(wù)
在 Windows 上編譯
已編譯了以下模塊,可供測(cè)試(需要 VC14 運(yùn)行庫(kù)):
# php7.0 64位 線程安全版 php_tonyenc_php70_ts_VC14_x64.dll # php7.0 64位 線程非安全版 php_tonyenc_php70_nts_VC14_x64.dll
手動(dòng)編譯方法
加密
代碼中的 tonyenc.php
是加密工具:
php tonyenc.php example.php dir/
這樣即可加密 example.php
和 dir
目錄下的所有 php 文件,PHP 在運(yùn)行它們時(shí)會(huì)自動(dòng)解密,夠簡(jiǎn)單吧