PHP source code encryption is sometimes necessary, otherwise all the code may be stolen by others, and some confidential information may also be stolen. We only introduce one encryption method for PHP source code: Screw.
Installation method:
Download link:
https://sourceforge.net/projects/php-screw/files/php -screw/
Open the URL
Click to download.
Put the file on the Linux server and execute the command:
tar zxvf php_screw-1.5.tar.gz cd php_screw-1.5 vi php_screw.h #将 #define PM9SCREW "\tPM9SCREW\t" #define PM9SCREW_LEN 10 #修改为任意字串,如: #define PM9SCREW "\tPHPENC\t" #define PM9SCREW_LEN 6 #如果不改这个文件,加密的文件内容开头就会有 PM9SCREW,这么做是为了隐藏加密算法。 vi my_screw.h #修改加密密钥: short pm9screw_mycryptkey[] = {11152, 368, 192, 1281, 62}; #修改为如: short pm9screw_mycryptkey[] = {18822, 668, 185, 1911, 82, 669}; #越长加密越可靠,建议不要大于5位数。 phpize ./configure --with-php-config=PATH(php_config路径不知道的就执行命令 find / -name php-config) make
If the compilation error is reported, modify the php_screw.c file:
Put CG (extended_info) = 1;
Modify to CG(compiler_options) |= ZEND_COMPILE_EXTENDED_INFO;
Remake;
Then cd tools
Execute make to generate screw tool
Execute cp tools/screw /usr/bin/screw (command used globally, otherwise it will prompt that the command cannot be found)
Find the php.ini file
Add: extension=php_screw.so (note The path of php_screw.so must be placed under the default extension lib folder of php otherwise it cannot be found)
The php_screw.so file is generated under the modules folder and you can find it yourself and copy it to the extension lib folder of php Go below.
After execution
php -m you can see the expanded file
##Test whether it can be encrypted:An encrypted file and a source file, so far it has been successful. File comparison. Commonly used commands:
find ./ -name "*.php" -print|xargs -n1 screw //加密所有的.php文件 find ./ -name "*.screw" -print|xargs -n1 rm //删除所有的.php源文件的备份文件
PHP tutorial!
The above is the detailed content of PHP uses Screw to encrypt source code. For more information, please follow other related articles on the PHP Chinese website!