這篇文章主要介紹了關於PHP原始碼php-beast加密,有著一定的參考價值,現在分享給大家,有需要的朋友可以參考一下
php-beast原始碼下載位址:
https://github.com/liexusong/php-beast
解壓縮,並進入原始碼目錄
[innpay@localhost soft]$ unzip php-beast-master.zip [innpay@localhost soft]$ cd php-beast-master [innpay@localhost php-beast-master]$ pwd/home/pony/soft/php-beast-master
編譯,安裝
[innpay@localhost php-beast-master]$ /home/pony/php/bin/phpize Configuring for: PHP Api Version: 20131106Zend Module Api No: 20131226Zend Extension Api No: 220131226[innpay@localhost php-beast-master]$ ./configure --with-php-config=/home/pony/php/bin/php-config [innpay@localhost php-beast-master]$ make [innpay@localhost php-beast-master]$ make install Installing shared extensions: /home/pony/php/lib/php/extensions/no-debug-non-zts-20131226/
安裝完成後,產生beast.so在no-debug-non-zts-20131226這個目錄下。
編輯php.ini,加入設定項: extension=beast.so
重啟apache,透過phpinfo查看beast是否生效
[innpay@localhost apache2]$ ./bin/apachectl restart
安裝完成後, 進入原始碼目錄下的tools目錄,設定configure.ini
[innpay@localhost tools]$ cat configure.ini ; source path src_path = "/home/pony/php/apache2/htdocs/wechat_nofity"; destination path dst_path = "/home/pony/php/apache2/htdocs/des"; expire time expire = "2019-01-01 12:00:00"; encrypt typeencrypt_type = "DES"
src_path 是要加密專案的路徑,dst_path 是儲存加密後專案的路徑,expire 是設定專案可使用的時間(expire 的格式是:YYYY-mm-dd HH:ii:ss)。 encrypt_type是加密的方式,選擇項目有:DES、AES、BASE64。修改完 configure.ini 檔案後就可以使用指令 php encode_files.php 開始加密專案。
這裡可能遇到執行php指令無法辨識的問題:
php: command not found
解決方法是把php的執行路徑加入.bash_profile環境變數的PATH中
#執行加密操作:
[innpay@localhost tools]$ php encode_files.php Source code path: /home/pony/php/apache2/htdocs/wechat_nofity Destination code path: /home/pony/php/apache2/htdocs/des Expire time: 2019-01-01 12:00:00------------- start process -------------PHP Warning: strtotime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /home/pony/php/soft/php-beast-master/tools/encode_files.php on line 147Warning: strtotime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /home/pony/php/soft/php-beast-master/tools/encode_files.php on line 147Processed encrypt files [64%] - 100%Failed to encode file `/home/pony/php/apache2/htdocs/wechat_nofity/wechat.class.php' Processed encrypt files [100%] - 100% Finish processed encrypt files, used 0.699295 seconds
這裡提示我有一個名為wechat.class.php的檔案加密失敗,我懷疑是檔案太長導致的,沒關係有一個不成功我就單獨拷貝過去。
加密後的目錄是des目錄,進去看下原始碼文件,確實都是亂碼。但是訪問所有的php頁面都是正常的。
因為我這裡用的是des加密方法,一定會用到一個des密鑰,缺省的密鑰在php-beast目錄下的des_algo_handler. c檔裡:
#include <stdlib.h>#include <string.h>#include "beast_module.h"#include "des_algo_lib.c"static char key[8] = { 0x01, 0x1f, 0x01, 0x1f, 0x01, 0x0e, 0x01, 0x0e, };
可以直接改,改完重新編譯即可。
以上就是本文的全部內容,希望對大家的學習有所幫助,更多相關內容請關注PHP中文網!
相關推薦:
以上是PHP源碼php-beast加密的詳細內容。更多資訊請關注PHP中文網其他相關文章!