Home > Backend Development > PHP7 > A cryptographic extension for PHP7 code

A cryptographic extension for PHP7 code

coldplay.xixi
Release: 2023-02-17 18:10:01
forward
3996 people have browsed it

PHP7 column introduces how to encrypt extensions

A cryptographic extension for PHP7 code

## Recommended:

PHP7

Introduction

A simple, high-performance, cross-platform PHP7 code encryption extension


Features

    Simple and fast, after actual testing, it has almost no impact on performance
  • Compatible with OPcache, Xdebug and other extensions
  • Supports Linux, macOS, Windows and other systems
  • Compatible with Apache, Nginx PHP-fpm, command line and other operating modes
  • The encryption algorithm is relatively simple, this is for speed considerations, but it is still difficult to decrypt
  • If the project has a lot of php files, you can only encrypt some important codes
  • Requires PHP >= 7.0
Installation

Please make the following modifications in

core.h before compiling:

/* 这里定制你的加密特征头,不限长度,十六进制哦 */
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,
};
Copy after login
Compile on Linux and macOS

git clone https://github.com/lihancong/tonyenc.git
cd tonyenc
phpize
./configure
make
Copy after login

Add the compiled file modules/tonyenc.so to the configuration item extension=tonyenc.so and restart the PHP service

Compile on Windows

The following modules have been compiled and are available Test (requires VC14 runtime library):

# php7.0 64位 线程安全版
php_tonyenc_php70_ts_VC14_x64.dll
# php7.0 64位 线程非安全版
php_tonyenc_php70_nts_VC14_x64.dll
Copy after login
Manual compilation method

Encryption

tonyenc.php in the code is the encryption tool:

php tonyenc.php example.php dir/
Copy after login
This way you can encrypt all php files in the

example.php and dir directories, and PHP will automatically decrypt them when running them. It's simple enough.

The above is the detailed content of A cryptographic extension for PHP7 code. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:learnku.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template