There are many software for encrypting PHP programs. The most commonly used one is the one on the official website, but it requires a fee. Now I will introduce a software that uses php_screw, which can also encrypt PHP programs. Let’s see an example below.
PHP_Screw is a free PHP extension that encrypts PHP source code. You can customize the encrypted seed file. The efficiency of the encrypted file will not decrease and it has not been cracked yet. Here’s how to install and use it
The latest version is php_screw_1.5
wget http://nchc.dl.sourceforge.net/project/php-screw/php-screw/1.5/php_screw-1.5.tar.gz
Only the source code can be downloaded from the official website
Download the latest version from the official site:
http://sourceforge.net/project/showfiles.php?group_id=52025
Installation steps:
1. Download source code:
<font face="NSimsun">wget http://nchc.dl.sourceforge.net/project/php-screw/php-screw/1.5/php_screw-1.5.tar.gz</font>
2. Unzip:
<font face="NSimsun">tar zxvf php_screw_1.5.tar.gz</font>
3. From the README.en file, you can see that this version of the package requires a PHP5.x environment and requires zlib support (check by executing the script). If you are using PHP4.X version, please download php_screw_1.3 version
4. Enter the source code directory
#cd php_screw_1.5<code>#cd php_screw_1.5<br>
root@Server:~/php_screw-1.5# vim php_screw.h<br>
#define PM9SCREW “tPM9SCREWt”<br>
#define PM9SCREW_LEN 10<br>
#define PM9SCREW “tLAURENCEt”<br>
#define PM9SCREW_LEN 9
root@Server:~/php_screw-1.5# vim php_screw.h
#define PM9SCREW “tPM9SCREWt”
#define PM9SCREW_LEN 10
#define PM9SCREW “tLAURENCEt”
#define PM9SCREW_LEN 9
5. php_screw.h file. If you do not change this file, the content of your encrypted file will have PM9SCREW at the beginning. If you copy it and search on Google, you will know that it is encrypted with the screw module. Although there is currently no decryption algorithm found on the Internet. But that won’t be the case in the future. This is done to hide the encryption algorithm so that others don’t know what algorithm you used to encrypt it. After changing to COOL, 10 should also be changed to 6. Because the character length after LAURENCE is 9 characters, if you do not support encryption, it cannot be decrypted and parsed.
my_screw.h
root@Server:~/php_screw-1.5# vim my_screw.h
short pm9screw_mycryptkey[] = {
11152, 368, 192, 1281, 62
};
12852, 968, 192, 1281, 62, 269
};
Customize the encrypted seed file. This may be the highlight of the program. Use your favorite text editor to open my_screw.h in the source directory and modify the array file in the file. You can use numbers to add the length of the array. The longer the array, the more reliable the encryption. Moreover, the length of the array will not affect the encryption and the execution speed of your PHP program. The test found that it should not be larger than 5 digits. If it is larger, there will be problems with decryption and parsing. #phpize<br>
Configuring for:<br>
PHP Api Version: 20041225<br>
Zend Module Api No: 20060613<br>
Zend Extension Api No: 220060519
6. phpize
#phpize<br>
Configuring for:<br>
PHP Api Version: 20041225<br>
Zend Module Api No: 20060613<br>
Zend Extension Api No: 220060519
If your system prompts that there is no such command, you need to install apt-get install php5-dev Centos. It is estimated to be yum -y install php5-devel. If it still prompts that the above command does not exist, it may be because your php is not installed in the standard directory, please search in the bin folder of the PHP installation directory to determine whether the file exists. Then go back to the php_scre_1.5 directory and execute
#/full/path/to/phpize
To successfully execute phpize, the autoconf and M4 packages are required. After successful execution, the configure file ./configure
appears in the source code folder.
If it is not installed the error is as follows: phpize command not found
Solution: centOS: yum -y install php-devel
:RHEL :up2date -i php-devel
<font face="NSimsun">./configure –with-php-config=/full/path/to/php-config</font>
7. Configuration
make
If php is installed in a non-standard directory, you need to check whether there is a php-config file in the phpize directory, and then execute the directory as follows
<code>make install
./configure –with-php-config=/full/path/to/php-config
8. Installation
Sometimes a problem will arise at this time:
'zend_compiler_globals' has no member named 'extended_info' make: *** [php_screw.lo] Error 1
Solution:
Need to modify php_screw.c (there are two places that need to be adjusted)
Set CG(extended_info) = 1;
CG(compiler_options) |= ZEND_COMPILE_EXTENDED_INFO;
9. php configuration#make
Add extension
in php.ini file
vim /usr/local/php/etc/php.ini
extension=php_screw.so
10. Go to the tools directory under the source code directory
<font face="NSimsun">#screw phpinfo.php</font>
#screw phpinfo.php
2. One disadvantage of php_screw_1.5 is that the screw encryption tool can only execute one file at a time. If you switch to your php source code directory to execute
#screw *
No files will be encrypted, it would be a disaster
if you want to encrypt hundreds of files
The solution is as follows, execute
find /data/php/source -name “*.php” -print|xargs -n1 screw //Encrypt all .php files
find /data/php/source -name “*.screw” -print|xargs -n1 rm //Delete the backup files of all .php source files
All files with the suffix php in the /path/to/php/source directory can be encrypted, including those in subdirectories.
In this way, the encryption of the PHP source code is basically achieved. If you just want to encrypt the source code of a personal small program, I think php_screw is a good choice