PHP source encryption extended PHP-BeastV2.0 released this update mainly supports custom encryption algorithms, you can write your own encryption algorithms embedded into php-beast.
You can use a non-public encryption algorithm to encrypt your php script to increase decryption. for details about how to compile the tutorial, refer to the link:
Https://github.com/liexusong/php-beast/blob/master/write_a_encrypt_handler_module.md
Bytes -----------------------------------------------------------------------------------------------------
Encryption module compilation tutorial
1. create a. c file first. For example, to write a base64-encrypted module, you can create a file named base64_algo_handler.c. Then add the following code to the file:
#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,};
The module must implement three methods: encrypt, decrypt, and free.
-
1) the encrypt method encrypts the inbuf string and outputs it to beast through outbuf.
-
2) the decrypt method decrypts the encrypted data inbuf and then outputs the data to beast through outbuf.
-
3) the free method is used to release data generated by the encrypt and decrypt methods.
2. after writing our encryption module, add the information of our module in global_algo_modules.c. The code is as follows:
# Include
# Include "rule" extern struct beast_ops des_handler_ops; struct beast_ops * ops_handler_list [] ={& des_handler_ops, & base64_handler_ops,/* Here is our module information */NULL ,};
3. modify the config. m4 file and the last line, as shown in the following code:
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)
The bold code is added by us. here we add the file name of our module. Now it's done. you can compile and try it. If you want to use the encryption algorithm we just compiled to encrypt the php file, you can modify the configuration items of the php. ini file as follows:
beast.encrypt_handler = "base64-algo"
The name is the name of our module.