解析如何用php screw加密php原始碼_PHP教程

來源:互聯網
上載者:User
在使用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<5000000;$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檔案就全部背加密了

http://www.bkjia.com/PHPjc/327734.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/327734.htmlTechArticle在使用PHP過程中發現,自己編寫的php代碼因為都是原始碼方式放在伺服器上的所以很容易就被別人拿走隨便修改(變成自己開發的)使用了...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    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.