Analyze how to use php screw to encrypt php source code_PHP tutorial

WBOY
Release: 2016-07-21 15:04:56
Original
887 people have browsed it

In the process of using PHP, I found that because the PHP code I wrote was placed on the server in the form of source code, it could easily be taken away and modified by others (to be developed by myself) and used.
In order to protect the fruits of my labor, I have been looking for a software that can encrypt PHP code.
The most famous one is Zend’s Zendencoder, but it is not an open source software (the price is very high and no cracked version has been found).
Since we can’t afford the paid ones, we will use open source ones. I found the open source software php_screw. The latest version is 1.5
Installation environment
System: centos 5.3
Software: Apache 2.2.9
PHP 5.2.10
All the above environments are downloaded, configured and installed by yourself. Please search the Internet for specific Apache+php+mysql installation methods.
Installation
1. Use tar to decompress tar -zxvf php_screw-1.5.tar.gz
2. Enter the php_screw-1.5 directory to start the installation
cd php_screw-1.5
phpize
About phpize, it only needs to install the php5-dev module in the php5-dev extension module.
./confiugre
3. Set your own password for encryption

Copy code The code is as follows:

vi my_screw.h
-- Please change the encryption SEED key (pm9screw_mycryptkey) into the
values ​​according to what you like.
The encryption will be harder to break, if you add more values ​​to the
encryption SEED array. However, the size of the SEED is unrelated to
the time of the decrypt processing.
* If you can read and understand the source code , to modify an original
encryption logic will be possible. But in general, this should not
be necessary.
OPTIONAL: Encrypted scripts get a stamp added to the beginning of the
file. If you like, you may change this stamp defined by
          PM9SCREW and PM9SCREW_LEN in php_screw.h. PM9SCREW_LEN must
                     be less than or equal to the size of PM9SCREW. >4. Compile

make
5. Copy the php_screw.so file in the modules directory to the /usr/lib/php5/extension directory

cp modules/php_screw.so /usr/lib/php5/extension/
6. Edit the php.ini file

in the php.ini file , add the following statement extension=php_screw.so
7. Restart Apache


/srv/apache/bin/apachectl restart
8. Compile encryption tools

cd toolsmake
9. Copy the encryption tool screw in the tools directory to the appropriate directory


cp screw /usr/bin/After the above 10 steps, php_screw-1.5 has been completely installed. And now PHP also supports interpretation of encrypted PHP files
Use
1. Now write a PHP file to be encrypted.

I wrote the following test.php file to test php speed


Copy the code

The code is as follows:
$a=0;$t=time();
for($i=0;$i<5000000;$i++)
{$a= $a*$i;}
$t1=time();
echo "

";
echo "It used:";
echo $t1-$t;
echo "seconds";
?>


Put the above test.php file in the /var/www/ directory. Accessing through the browser will show the speed of PHP in large-scale calculations (rough estimate)
2. Encrypt the PHP file we wrote
cd /var/www/
screw test.php
After we encrypt it, the test.php file in the directory is now encrypted. The source file was renamed test.php.screw and stored.
Let’s test test.php now to see if it can be used normally? How is the speed?
I compared it and found that the speed before and after encryption is about the same, and there is basically not much loss.
3. Batch encrypted files
After testing on debian, apache2, php5 to encrypt the .html file, it can be parsed correctly;
How does php_screw work on the directory in the current directory? Files included under the directory and files in the included directory are encrypted as a whole
find ./ -name "*.php"-print|xargs -n1 screw //Encrypt all .php files
find ./ -name "*.screw" -print/xargs -n1 rm //Delete the backup files of all .php source files
In this way, all .php files in the current directory will be encrypted

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/327734.htmlTechArticleIn the process of using PHP, I found that the php codes I wrote were all placed on the server in the form of source code. It is easy for others to take it away and modify it (turn it into one’s own development) and use it...
source:php.cn
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!