PHP 源码加密扩展 PHP-Beast V2.0 发布
此次更新主要支持自定义加密算法,你可以通过编写自己的加密算法嵌入到php-beast中。
你可以使用非公开的加密算法来加密你的php脚本,从而增加解密的难道. 具体编写教程可以参考链接:
https://github.com/liexusong/php-beast/blob/master/write_a_encrypt_handler_module.md
-----------------------------------------------------------------------------------------------------
加密模块编写教程
一、首先创建一个.c的文件。例如我们要编写一个使用base64加密的模块,可以创建一个名叫base64_algo_handler.c的文件。然后在文件添加如下代码:
#include "beast_module.h"int base64_encrypt_handler(char *inbuf, int len, char **outbuf, int *outlen){ ...}int base64_decrypt_handler(char *inbuf, int len, char **outbuf, int *outlen){ ...}void base64_free_handler(void *ptr){ ...}struct beast_ops base64_handler_ops = { .name = "base64-algo", .encrypt = base64_encrypt_handler, .decrypt = base64_decrypt_handler, .free = base64_free_handler,};
模块必须实现3个方法,分别是:encrypt、decrypt、free方法。
-
1) encrypt方法负责把inbuf字符串加密,然后通过outbuf输出给beast。
-
2) decrypt方法负责把加密数据inbuf解密,然后通过outbuf输出给beast。
-
3) free方法负责释放encrypt和decrypt方法生成的数据。
二、写好我们的加密模块后,需要在global_algo_modules.c添加我们模块的信息。代码如下:
#include <stdlib.h>#include "beast_module.h"extern struct beast_ops des_handler_ops;struct beast_ops *ops_handler_list[] = { &des_handler_ops, &base64_handler_ops, /* 这里是我们的模块信息 */ NULL,};
三、修改config.m4文件,修改倒数第二行,如下代码:
PHP_NEW_EXTENSION(beast, beast.c des_algo_handler.c beast_mm.c spinlock.c cache.c beast_log.c global_algo_modules.c base64_algo_handler.c, $ext_shared)
加粗的代码是我们添加的,这里加入的是我们模块的文件名。现在大功告成了,可以编译试下。如果要使用我们刚编写的加密算法来加密php文件,可以修改php.ini文件的配置项,如下:
beast.encrypt_handler = "base64-algo"
名字就是我们模块的name。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Long URLs, often cluttered with keywords and tracking parameters, can deter visitors. A URL shortening script offers a solution, creating concise links ideal for social media and other platforms. These scripts are valuable for individual websites a

Laravel simplifies handling temporary session data using its intuitive flash methods. This is perfect for displaying brief messages, alerts, or notifications within your application. Data persists only for the subsequent request by default: $request-

This is the second and final part of the series on building a React application with a Laravel back-end. In the first part of the series, we created a RESTful API using Laravel for a basic product-listing application. In this tutorial, we will be dev

Laravel provides concise HTTP response simulation syntax, simplifying HTTP interaction testing. This approach significantly reduces code redundancy while making your test simulation more intuitive. The basic implementation provides a variety of response type shortcuts: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

The 2025 PHP Landscape Survey investigates current PHP development trends. It explores framework usage, deployment methods, and challenges, aiming to provide insights for developers and businesses. The survey anticipates growth in modern PHP versio

In this article, we're going to explore the notification system in the Laravel web framework. The notification system in Laravel allows you to send notifications to users over different channels. Today, we'll discuss how you can send notifications ov
