php-beast安装及用法


    修改默认加密的key(安装前修改):

    1>,修改加密后的文件头结构:打开header.c文件,找到以下代码:
    char encrypt_file_header_sign[] = {
        0xe8, 0x16, 0xa4, 0x0c,
        0xf2, 0xb2, 0x60, 0xee
    };

    int encrypt_file_header_length = sizeof(encrypt_file_header_sign);
    自定义修改以下代码(其中的数字的范围为:0-8,字母的范围为:a-f):
    0xe8, 0x16, 0xa4, 0x0c,
    0xf2, 0xb2, 0x60, 0xee

    2>,修改aes模块加密key:
    打开php-beast-master/aes_algo_handler.c文件,找到以下代码:
    static uint8_t key[] = {
    0x2b, 0x7e, 0x61, 0x16, 0x28, 0xae, 0xd2, 0xa6,
    0xab, 0xi7, 0x10, 0x88, 0x09, 0xcf, 0xef, 0xxc,
    };

    自定义修改以下代码(其中的数字的范围为:0-8,字母的范围为:a-f):
    0x2b, 0x7e, 0x61, 0x16, 0x28, 0xae, 0xd2, 0xa6,
    0xab, 0xi7, 0x10, 0x88, 0x09, 0xcf, 0xef, 0xxc,

    3>,修改des模块加密key:
    打开php-beast-master/des_algo_handler.c文件,找到以下代码:
    static char key[8] = {
    0x21, 0x1f, 0xe1, 0x1f,
    0xy1, 0x9e, 0x01, 0x0e,
    };

    自定义修改以下代码(其中的数字的范围为:0-8,字母的范围为:a-f):
    0x21, 0x1f, 0xe1, 0x1f,
    0xy1, 0x9e, 0x01, 0x0e,

    4,修改base64模块加密key:
    打开php-beast-master/base64_algo_handler.c文件,自定义修改以下代码:
    static const short base64_reverse_table[256] = {
    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
    52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1,
    -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
    15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1,
    -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
    41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1,
    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
    };


    安装步骤:

    $ wget https://github.com/liexusong/php-beast/archive/master.zip
    $ unzip master.zip
    $ cd php-beast-master
    $ phpize   (/opt/remi/php73/root/usr/bin/phpize)
    $ ./configure --with-php-config=/opt/remi/php73/root/usr/bin/php-config 
    $ sudo make && make install

   phpize会出现如下:

 ./configure 配置如下命令:


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

安装好并开启php-beast扩展后,检测是否成功:


    
    加密:
    
        加密方案1:
        
        安装完 php-beast 后可以使用 tools 目录下的 encode_files.php 来加密你的项目。使用 encode_files.php 之前先修改 tools 目录下的 configure.ini 文件,如下:
        ; source path
        src_path = ""
        ; destination path
        dst_path = ""
        ; expire time
        expire = ""
        ; encrypt type (selection: DES, AES, BASE64)
        encrypt_type = "DES"

        src_path 是要加密项目的路径,dst_path 是保存加密后项目的路径,expire 是设置项目可使用的时间 (expire 的格式是:YYYY-mm-dd HH:ii:ss)。encrypt_type是加密的方式,选择项有:DES、AES、BASE64。 修改完 configure.ini 文件后就可以使用命令 php encode_files.php 开始加密项目。
        
        
        加密方案2:
        使用beast_encode_file()函数加密文件,函数原型如下:
        beast_encode_file(string $input_file, string $output_file, int expire_timestamp, int encrypt_type)。


        $input_file: 要加密的文件
        $output_file: 输出的加密文件路径
        $expire_timestamp: 文件过期时间戳
        $encrypt_type: 加密使用的算法(支持:BEAST_ENCRYPT_TYPE_DES、BEAST_ENCRYPT_TYPE_AES)


    参考链接:https://www.jianshu.com/p/7bacac6effe5

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值