解析如何用php screw加密php源代码
在使用PHP过程中发现,自己编写的php代码因为都是源代码方式放在服务器上的所以很容易就被别人拿走随便修改(变成自己开发的)使用了。
为了保住自己的劳动成果,我一直寻找一种可以加密php代码的软件。
最著名的就是Zend公司的Zendencoder了,但是不是开源软件(要价很高,也没有找到破解版)。
既然收费的用不起,我们就用开源的。我找到了php_screw这个开源软件,目前最新版本是1.5
安装环境
系统:centos 5.3
软件:Apache 2.2.9
PHP 5.2.10
以上环境全部是自己下载配置安装的。具体的Apache+php+mysql安装方法请从网上搜索。
安装
1.用tar解压缩 tar -zxvf php_screw-1.5.tar.gz
2.进入php_screw-1.5目录开始安装
cd php_screw-1.5
phpize
关于phpize ,它在php5-dev扩展模块中 只要安装php5-dev模块就行了。
./confiugre
3.设置自己用来加密的密码
复制代码 代码如下:
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.编译
make
5.拷贝modules目录下的php_screw.so文件到/usr/lib/php5/extension目录下
cp modules/php_screw.so /usr/lib/php5/extension/
6.编辑php.ini文件
在php.ini文件里,加入如下语句
extension=php_screw.so
7.重新启动Apache
/srv/apache/bin/apachectl restart
8.编译加密工具
cd tools
make
9.将tools目录下加密用的工具screw拷贝到适当目录
cp screw /usr/bin/
经过以上的10步,就已经把php_screw-1.5全部安装完成了。并且现在的php也已经支持解释加密过的php文件了
使用
1.现写一个要加密的php文件。
我写了如下的一个用来测试php速度的test.php文件
复制代码 代码如下:
$a=0;
$t=time();
for($i=0;$i {$a=$a*$i;}
$t1=time();
echo "
";
echo "It used:";
echo $t1-$t;
echo "seconds";
?>
将上面的test.php文件放到/var/www/目录下。通过浏览器访问,将显示出php在大量计算时的速度(粗略估计)
2.将我们写的php文件加密
cd /var/www/
screw test.php
我们加密后,现在目录下的test.php文件就是我们已经加密的了。而源文件被改名为test.php.screw存放了。
我们现在再测试一下test.php,看看能否正常使用?速度如何?
我比较了一下,加密前后的速度大概一样,基本没有太多的损失。
3.批处理加密文件
在debian, apache2, php5上测试过对.html文件加密后,能正确解析;
php_screw如何对当前目录下,对目录下包含的文件,以及包含目录下的文件进行整体加密
find ./ -name "*.php"-print|xargs -n1 screw //加密所有的.php文件
find ./ -name "*.screw" -print/xargs -n1 rm //删除所有的.php源文件的备份文件
这样在当前目录下的所有.php文件就全部背加密了

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

What are the magic methods of PHP? PHP's magic methods include: 1.\_\_construct, used to initialize objects; 2.\_\_destruct, used to clean up resources; 3.\_\_call, handle non-existent method calls; 4.\_\_get, implement dynamic attribute access; 5.\_\_set, implement dynamic attribute settings. These methods are automatically called in certain situations, improving code flexibility and efficiency.

PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

PHP is widely used in e-commerce, content management systems and API development. 1) E-commerce: used for shopping cart function and payment processing. 2) Content management system: used for dynamic content generation and user management. 3) API development: used for RESTful API development and API security. Through performance optimization and best practices, the efficiency and maintainability of PHP applications are improved.

PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7

PHP and Python each have their own advantages, and the choice should be based on project requirements. 1.PHP is suitable for web development, with simple syntax and high execution efficiency. 2. Python is suitable for data science and machine learning, with concise syntax and rich libraries.

In PHP8, match expressions are a new control structure that returns different results based on the value of the expression. 1) It is similar to a switch statement, but returns a value instead of an execution statement block. 2) The match expression is strictly compared (===), which improves security. 3) It avoids possible break omissions in switch statements and enhances the simplicity and readability of the code.
