This article mainly introduces the PHP source code php-beast Encryption, has a certain reference value, now share to everyone, the need for friends can refer to
Installing Php-beast
Php-beast Source Download Address:
Https://github.com/liexusong/php-beast
Unzip, and enter the source directory
[Innpay@localhost soft]$ unzip Php-beast-master.zip [innpay@localhost soft]$ CD Php-beast-master[innpay@localhost php-beast-master]$ Pwd/home/pony/soft/php-beast-master
Compile, install
[Innpay@localhost php-beast-master]$/home/pony/php/bin/phpize Configuring for:php Api Version: 20131106Zend Module API No: 20131226Zend Extension API No: 220131226[innpay@localhost php-beast-master]$./configure-- With-php-config=/home/pony/php/bin/php-config[innpay@localhost php-beast-master]$ Make[innpay@localhost php-beast-master]$ make installinstalling Shared extensions: /home/pony/php/lib/php/extensions/ no-debug-non-zts-20131226/
After the installation is complete, generate beast.so in the no-debug-non-zts-20131226 directory.
Edit PHP.ini, add configuration entry: extension=beast.so
Restart Apache to see if Beast is in effect with Phpinfo
[Innpay@localhost apache2]$./bin/apachectl restart
Using Php-beast
After the installation is complete, go to the Tools directory under the source directory and configure the Configure.ini
[Innpay@localhost tools]$ cat Configure.ini; SOURCE Pathsrc_path = "/home/pony/php/apache2/htdocs/wechat_nofity"; Destination Pathdst_path = "/home/pony/php/apache2/htdocs/des"; Expire Timeexpire = "2019-01-01 12:00:00"; Encrypt typeencrypt_type = "DES"
Src_path is the path to encrypt the project, Dst_path is the path to save the encrypted project, expire is the time to set the project to work (expire format: Yyyy-mm-dd HH:ii:ss). The Encrypt_type is encrypted in a way that has the following options: DES, AES, BASE64. After modifying the Configure.ini file, you can start encrypting the project using the command PHP encode_files.php.
You may encounter an issue that does not recognize the PHP command:
Php:command not found
The workaround is to add the PHP execution path to the. Bash_profile environment variable in path
To perform an encryption operation:
[Innpay@localhost tools]$ PHP encode_files.phpsource code path:/home/pony/php/apache2/htdocs/wechat_ Nofitydestination code path:/home/pony/php/apache2/htdocs/desexpire time:2019-01-01 12:00:00-------------Start Process-------------PHP warning:strtotime (): It is not safe for rely on the system ' s timezone settings. You is *required* to use the Date.timezone setting or the Date_default_timezone_set () function. In case you used any of those methods and you is still getting this warning, your most likely misspelled the timezone Iden Tifier. We selected the timezone ' UTC ' for now, but please set Date.timezone to select your timezone. in/home/pony/php/soft/php-beast-master/tools/encode_files.php on Line 147warning:strtotime (): It isn't safe to rely on The system ' s timezone settings. You is *required* to use the Date.timezone setting or the Date_default_timezone_set () function. In case you used any of the those methods and you is still getting this warning, your most likely misspelled the timezone identifier. We selected the timezone ' UTC ' for now, but please set Date.timezone to select your timezone. in/home/pony/php/soft/php-beast-master/tools/encode_files.php on line 147Processed encrypt files [64%]-100%failed to E ncode file '/home/pony/php/apache2/htdocs/wechat_nofity/wechat.class.php ' processed encrypt files [100%]-100%finish Processed encrypt files, used 0.699295 seconds
Here is a hint that I have a file named wechat.class.php encryption failed, I suspect that the file is too long caused, it doesn't matter if one of the unsuccessful I copy the past alone.
After the encrypted directory is the DES directory, go in to see the source file, it is really garbled. However, access to all PHP pages is normal.
Modifying the default encryption key
Because I use the DES encryption method here, will definitely use a des key, the default key in the Php-beast directory in the des_algo_handler.c file:
#include <stdlib.h> #include <string.h> #include "beast_module.h" #include "des_algo_lib.c" static char key[ 8] = { 0x01, 0x1f, 0x01, 0x1f, 0x01, 0x0e, 0x01, 0x0e,};
Can be changed directly, the re-compilation can be completed.
The above is the whole content of this article, I hope that everyone's learning has helped, more relevant content please pay attention to topic.alibabacloud.com!