Parsing how to use PHP screw to encrypt PHP source code _php Tips

Source: Internet
Author: User
Tags php source code
In the use of PHP process found that the PHP code you have written because the source code is placed on the server, so it is easy to be taken away by others casually modified (into their own development) use.
I've been looking for a software that can encrypt PHP code in order to keep the fruits of my labor.
The most famous is the Zend Company's Zendencoder, but is not open source software (high price, also did not find a cracked version).
Since the charge is not affordable, we use open source. I found php_screw this open source software, the latest version is now 1.5
Installation Environment
System: CentOS 5.3
Software: Apache 2.2.9
PHP 5.2.10
All of the above environments are installed by downloading the configuration themselves. For specific Apache+php+mysql installation methods, please search from the Internet.
Installation
1. Extract TAR-ZXVF php_screw-1.5.tar.gz with tar
2. Enter the php_screw-1.5 directory to start the installation
CD php_screw-1.5
Phpize
As for phpize, it can be done in the Php5-dev extension module as long as the Php5-dev module is installed.
./confiugre
3. Set the password that you use to encrypt
Copy Code code as follows:

VI my_screw.h
--Please change the encryption SEED key (Pm9screw_mycryptkey) into the
Values according to what.
The encryption would be harder to break and 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 would 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 are like, I/May the 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 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 the Encryption tool
CD Tools
Make
9. Copy the tool screw to the appropriate directory in the Tools directory
CP screw/usr/bin/
After 10 steps, the php_screw-1.5 has been fully installed. And now PHP has already supported the explanation of the encrypted PHP file.
use
1. Now write a PHP file to encrypt.
I wrote the following test.php file to test the speed of PHP
Copy Code code as follows:

?
$a = 0;
$t =time ();
For ($i =0 $i <5000000; $i + +)
{$a = $a * $i;}
$t 1=time ();
echo "<p>";
echo "It used:";
echo $t 1-$t;
echo "seconds";
?>

Place the above test.php file in the/var/www/directory. Access through the browser will show the speed of PHP in a large number of calculations (rough estimate)
2. Encrypt the PHP file we write
cd/var/www/
Screw test.php
After we encrypt, the test.php file in the directory is now encrypted. And the source file is renamed for Test.php.screw storage.
Let's test the test.php now and see if we can use it properly? How's the speed?
I compared the speed of the encryption before and after about the same, basically do not have too much loss.
3. Batch processing Encrypted file
In Debian, Apache2, PHP5, after the test of the. html file encryption, can correctly parse;
Php_screw How to encrypt the files that are contained in the directory under the current directory and the files contained in the directory
Find./-name "*.php"-print|xargs-n1 screw//Encrypt all. php files
Find./-name "*.screw"-print/xargs-n1 RM//delete all. php Source files Backup files
This way all the. php files in the current directory are encrypted on the back.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.