记录学习与后端知识并分享学习代码过程(会飞的鱼Blog)

一个PHP7 代码的加密扩展

会飞的鱼 0 9073 2021年12月20日

安装
编译前请在 core.h 中做如下修改:

/* 这里定制你的加密特征头,不限长度,十六进制哦 */

const u_char tonyenc_header[] = {

        0x66, 0x88, 0xff, 0x4f,

        0x68, 0x86, 0x00, 0x56,

        0x11, 0x16, 0x16, 0x18,

};

/* 这里指定密钥,设置长一些更安全 */

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 服务

在 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 在运行它们时会自动解密,够简单吧。

本文由 @会飞的鱼 于 2021-12-20 发布在 会飞的鱼Blog,如无特别说明,本博文章均为原创,转载请保留出处。

网友评论

    暂无评论

会飞的鱼 V

一条会飞的鱼!

745 文章
7275 评论
1072 万 阅读
8年 博龄
最新文章
最新评论
嘻嘻嘻
2个月前 (2024-03-19)

ThinkPHP实现用户注册、登录模块

标签

会飞的鱼 在线咨询

在线时间:9:00-22:00
周六、周日:14:00-22:00