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