php 源码加密保护 bease方案

推荐使用 php-bease 这个免费开源方案。

有一说一,这个项目上次更新时间是2021年…

多好的项目呀。

作者说在 php5.1 ~ php7.2 上都测试过。

源码地址:

  • C源码: https://github.com/liexusong/php-beast

  • dll版: https://github.com/imaben/php-beast-binaries/tree/master/php72

Windows上使用

安装

安装(编译)过程就没有了, dll 都给你了,丢到 ext 目录里,再在 php.ini 里加载它就行

使用

源码库里提供了 ./tools/encode_files.php 脚本文件 和 配套的 configure.ini

填一下 configure.ini

; source path
src_path = "F:\\Export\\source"

; destination path
dst_path = "F:\\Export\\source_Encrypt"

; expire time
expire = "2099-12-31 23:59:59"

; encrypt type
encrypt_type = "DES"

然后跑一下encode_files.php脚本

# Shell
cd F:
cd php-beast-master\tools
D:/php7/php.exe -c D:/php7/php.ini ./encode_files.php

脚本就会把 指定目录里的所有 php 文件加密,输出到 输出目录 里,文件名不变。

加密后的 php 文件可以照!常!使!用!,但不可直接读 —— 显示乱码。

估计这个扩展的解密特性,生效在解释 PHP 源码之前: 解释器准备解释 a.php ,发现是密文,bease解密,将解密后的内容交给 解释器继续解释。

问题

  • Windows上都用这个 dll ,说明大家用的是同一个密钥呢,如何定制密钥呢?

  • 还是得学习下怎么把 bease 源码重新编译成 dll

Linux上使用

安装

  • 下载bease的C语言源码,手动编译成扩展,得到 xx.so
wget https://github.com/liexusong/php-beast/archive/master.zip
unzip master.zip
cd php-beast-master
phpize
./configure
make && make install
  • 修改 php.ini 加载这个 xx.so (一般不需要,编译后会自动加载上)

使用

  • 使用附带的 encode_files.phpencode_file.php 脚本 加密你想要加密的文件

  • 使用加密的文件替换原文件,照常使用就行

  • 可以调整密钥,请参考源码首页的说明

相关推荐

  1. php 加密保护 bease方案

    2024-01-27 11:02:01       27 阅读
  2. 几种PHP对称加密解密

    2024-01-27 11:02:01       31 阅读
  3. PHP AES加密保护数据安全的高级加密技术

    2024-01-27 11:02:01       41 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-01-27 11:02:01       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-01-27 11:02:01       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-01-27 11:02:01       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-01-27 11:02:01       18 阅读

热门阅读

  1. android studio开发的一些问题

    2024-01-27 11:02:01       36 阅读
  2. CentOS 7.9 OS Kernel Update 3.10 to 4.19

    2024-01-27 11:02:01       29 阅读
  3. 出现次数超过一半的数(c++题解)

    2024-01-27 11:02:01       31 阅读
  4. day32_CSS

    day32_CSS

    2024-01-27 11:02:01      31 阅读
  5. mac安装telnet命令

    2024-01-27 11:02:01       22 阅读
  6. mysql双机bin-log备份

    2024-01-27 11:02:01       39 阅读