很多站长朋友们都不太清楚php压缩加密,今天小编就来给大家整理php压缩加密,希望对各位有所帮助,具体内容如下:
本文目录一览: 1、 PHP判断上传上来的RAR文件是否被加密 2、 php怎样实现对zip文件的加密和解密 3、 明明是一些word 或是rar压缩格式的文件 我用迅雷下下来后怎么就是PHP格式的呢,然后什么也没有。。 4、 对php文件加密,有哪些免费软件,怎么加密? 5、 PHP主要应用那些方面? 6、 PHP的gzip压缩方法 ,为什么压缩了反而更慢了。尤其浏览器缓存js以后 PHP判断上传上来的RAR文件是否被加密fread文件
RAR构成到Winrar目录下找TechNote.txt
比较复杂,需要拆文件头,大概是0x17为80就是没加密的,加密的见过有C4,有84.(末尾都是4)
你再研究下.
===============
从文件外皮看不出是否加密的,必须拿到一点文件头才行,不了解客户端的程序,应该可以类似网易相册那样在客户机本地就完成判
php怎样实现对zip文件的加密和解密使用PHPZip类就可以解决的。以下是网上找到的例子。
$zipfiles =array("/root/pooy/test1.txt","/root/pooy/test2.txt");
$z = new PHPZip();
//$randomstr = random(8);
$zipfile = TEMP."/photocome_".$groupid.".zip";
$z->Zip($zipfiles, $zipfile);
<?php
#
# PHPZip v1.2 by Sext (sext@neud.net) 2002-11-18
# (Changed: 2003-03-01)
#
# Makes zip archive
#
# Based on "Zip file creation class", uses zLib
#
#
class PHPZip
{
function Zip($dir, $zipfilename)
{
if (@function_exists('gzcompress'))
{
$curdir = getcwd();
if (is_array($dir))
{
$filelist = $dir;
}
else
{
$filelist = $this -> GetFileList($dir);
}
if ((!empty($dir))(!is_array($dir))(file_exists($dir))) chdir($dir);
else chdir($curdir);
if (count($filelist)>0)
{
foreach($filelist as $filename)
{
if (is_file($filename))
{
$fd = fopen ($filename, "r");
$content = fread ($fd, filesize ($filename));
fclose ($fd);
if (is_array($dir)) $filename = basename($filename);
$this -> addFile($content, $filename);
}
}
$out = $this -> file();
chdir($curdir);
$fp = fopen($zipfilename, "w");
fwrite($fp, $out, strlen($out));
fclose($fp);
}
return 1;
}
else return 0;
}
function GetFileList($dir)
{
if (file_exists($dir))
{
$args = func_get_args();
$pref = $args[1];
$dh = opendir($dir);
while($files = readdir($dh))
{
if (($files!=".")($files!=".."))
{
if (is_dir($dir.$files))
{
$curdir = getcwd();
chdir($dir.$files);
$file = array_merge($file, $this -> GetFileList("", "$pref$files/"));
chdir($curdir);
}
else $file[]=$pref.$files;
}
}
closedir($dh);
}
return $file;
}
var $datasec = array();
var $ctrl_dir = array();
var $eof_ctrl_dir = "x50x4bx05x06x00x00x00x00";
var $old_offset = 0;
/**
* Converts an Unix timestamp to a four byte DOS date and time format (date
* in high two bytes, time in low two bytes allowing magnitude comparison).
*
* @param integer the current Unix timestamp
*
* @return integer the current date in a four byte DOS format
*
* @access private
*/
function unix2DosTime($unixtime = 0) {
$timearray = ($unixtime == 0) ? getdate() : getdate($unixtime);
if ($timearray['year'] < 1980) {
$timearray['year'] = 1980;
$timearray['mon'] = 1;
$timearray['mday'] = 1;
$timearray['hours'] = 0;
$timearray['minutes'] = 0;
$timearray['seconds'] = 0;
} // end if
return (($timearray['year'] - 1980) << 25) | ($timearray['mon'] << 21) | ($timearray['mday'] << 16) |
($timearray['hours'] << 11) | ($timearray['minutes'] << 5) | ($timearray['seconds'] >> 1);
} // end of the 'unix2DosTime()' method
/**
* Adds "file" to archive
*
* @param string file contents
* @param string name of the file in the archive (may contains the path)
* @param integer the current timestamp
*
* @access public
*/
function addFile($data, $name, $time = 0)
{
$name = str_replace('', '/', $name);
$dtime = dechex($this->unix2DosTime($time));
$hexdtime = 'x' . $dtime[6] . $dtime[7]
. 'x' . $dtime[4] . $dtime[5]
. 'x' . $dtime[2] . $dtime[3]
. 'x' . $dtime[0] . $dtime[1];
eval('$hexdtime = "' . $hexdtime . '";');
$fr = "x50x4bx03x04";
$fr .= "x14x00"; // ver needed to extract
$fr .= "x00x00"; // gen purpose bit flag
$fr .= "x08x00"; // compression method
$fr .= $hexdtime; // last mod time and date
// "local file header" segment
$unc_len = strlen($data);
$crc = crc32($data);
$zdata = gzcompress($data);
$c_len = strlen($zdata);
$zdata = substr(substr($zdata, 0, strlen($zdata) - 4), 2); // fix crc bug
$fr .= pack('V', $crc); // crc32
$fr .= pack('V', $c_len); // compressed filesize
$fr .= pack('V', $unc_len); // uncompressed filesize
$fr .= pack('v', strlen($name)); // length of filename
$fr .= pack('v', 0); // extra field length
$fr .= $name;
// "file data" segment
$fr .= $zdata;
// "data descriptor" segment (optional but necessary if archive is not
// served as file)
$fr .= pack('V', $crc); // crc32
$fr .= pack('V', $c_len); // compressed filesize
$fr .= pack('V', $unc_len); // uncompressed filesize
// add this entry to array
$this -> datasec[] = $fr;
$new_offset = strlen(implode('', $this->datasec));
// now add to central directory record
$cdrec = "x50x4bx01x02";
$cdrec .= "x00x00"; // version made by
$cdrec .= "x14x00"; // version needed to extract
$cdrec .= "x00x00"; // gen purpose bit flag
$cdrec .= "x08x00"; // compression method
$cdrec .= $hexdtime; // last mod time date
$cdrec .= pack('V', $crc); // crc32
$cdrec .= pack('V', $c_len); // compressed filesize
$cdrec .= pack('V', $unc_len); // uncompressed filesize
$cdrec .= pack('v', strlen($name) ); // length of filename
$cdrec .= pack('v', 0 ); // extra field length
$cdrec .= pack('v', 0 ); // file comment length
$cdrec .= pack('v', 0 ); // disk number start
$cdrec .= pack('v', 0 ); // internal file attributes
$cdrec .= pack('V', 32 ); // external file attributes - 'archive' bit set
$cdrec .= pack('V', $this -> old_offset ); // relative offset of local header
$this -> old_offset = $new_offset;
$cdrec .= $name;
// optional extra field, file comment goes here
// save to central directory
$this -> ctrl_dir[] = $cdrec;
} // end of the 'addFile()' method
/**
* Dumps out file
*
* @return string the zipped file
*
* @access public
*/
function file()
{
$data = implode('', $this -> datasec);
$ctrldir = implode('', $this -> ctrl_dir);
return
$data .
$ctrldir .
$this -> eof_ctrl_dir .
pack('v', sizeof($this -> ctrl_dir)) . // total # of entries "on this disk"
pack('v', sizeof($this -> ctrl_dir)) . // total # of entries overall
pack('V', strlen($ctrldir)) . // size of central dir
pack('V', strlen($data)) . // offset to start of central dir
"x00x00"; // .zip file comment length
} // end of the 'file()' method
} // end of the 'PHPZip' class
?>
明明是一些word 或是rar压缩格式的文件 我用迅雷下下来后怎么就是PHP格式的呢,然后什么也没有。。尊敬的迅雷用户,您好:
这个情况,一般是由于下载的地址有限制,下载到跳转的连接或者是浏览器导致的。
1、登录这个页面,下载一个迅雷7的安装包测试查看一下是否出现同样的问题。
2、如测试下载迅雷安装包没出现同样情况,则是资源网站的问题,只能寻找其他下载源了。
3、如测试下载迅雷安装包出现了同样的情况,则请使用IE浏览器进行登录测试下载迅雷安装包尝试。
3、上述皆无效,请卸载迅雷然后登录这个页面下载迅雷7最新版本安装包,重新安装在另外一个磁盘上尝试。(请不要覆盖安装,必须卸载安装,不然可能会覆盖上旧问题)
更多疑问,欢迎您向迅雷网络平台提问。
对php文件加密,有哪些免费软件,怎么加密?php 源文件加密工具PHP Screw .
目前最新版本是1.3
网址
我的安装环境
系统:Slackware 10
软件:Apache 1.3.31
PHP 4.3.7
以上环境全部是slackware 10默认安装后自带的。具体的Apache+php+mysql安装方法参照如下
支持php的Apache环境安装
获得软件
下载php_screw-1.3 ()
安装
1.将获得的php_screw-1.3.tgz文件放到/usr/local目录下,然后用tar解压缩
tar zxvf php_screw-1.3.tgz
2.进入/usr/local/php_screw-1.3目录开始安装
cd /usr/local/php_screw-1.3
phpize
./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/php/extension目录下
cp modules/php_screw.so /usr/lib/php/extension/
6.编辑php.ini文件
在php.ini文件里,加入如下语句
extension=php_screw.so
7.重新启动Apache
/etc/rc.d/rc.httpd restart
8.编译加密工具
cd tools
make
9.将tools目录下加密用的工具screw拷贝到适当目录
cp screw /usr/bin/
经过以上的10步,就已经把php_screw-1.3全部安装完成了。并且现在的php也已经支持解释加密过的php文件了
使用
1.现写一个要加密的php文件。
我写了如下的一个用来测试php速度的compute.php文件
<?
$a=0;
$t=time();
for($i=0;$i<5000000;$i++)
{$a=$a*$i;}
$t1=time();
echo "<p>";
echo "It used:";
echo $t1-$t;
echo "seconds";
?>
将上面的compute.php文件放到/var/www/htdocs目录下。通过浏览器访问,将显示出php在大量计算时的速度(只能粗略估计一下)
2.将我们写的php文件加密
cd /var/www/htdocs/
screw compute.php
我们加密后,现在目录下的compute.php文件就是我们已经加密的了。而源文件被改名为compute.php.screw存放了。
我们现在再测试一下compute.php,看看能否正常使用?速度如何?
我比较了一下,加密前后的速度大概一样,基本没有太多的损失。
PHP主要应用那些方面?1、服务端脚本。
这是 PHP 最传统,也是最主要的目标领域。开展这项工作需要具备以下三点:
A、PHP 解析器(CGI 或者服务器模块)、
B、web 服务器、
C、web 浏览器。
需要在运行 web 服务器时,安装并配置 PHP,
然后,可以用 web 浏览器来访问 PHP 程序的输出,即浏览服务端的 PHP 页面。
如果只是实验 PHP 编程,所有的这些都可以运行在自己家里的电脑中。
2、命令行脚本。
可以编写一段 PHP 脚本,并且不需要任何服务器或者浏览器来运行它。
通过这种方式,仅仅只需要 PHP 解析器来执行。
这种用法对于依赖 cron(Unix 或者 Linux 环境)
或者 Task Scheduler(Windows 环境)的日常运行的脚本来说是理想的选择。
这些脚本也可以用来处理简单的文本。
3、编写桌面应用程序。
对于有着图形界面的桌面应用程序来说,PHP 或许不是一种最好的语言,
但是如果用户非常精通 PHP,并且希望在客户端应用程序中使用 PHP 的一些高级特性,
可以利用 PHP-GTK 来编写这些程序。用这种方法,还可以编写跨平台的应用程序。
PHP-GTK 是 PHP 的一个扩展,在通常发布的 PHP 包中并不包含它。
如果对 PHP-GTK 感兴趣,请访问其网站以获取更多信息。
php
PHP,是英文超文本预处理语言Hypertext Preprocessor的缩写。PHP 是一种 HTML 内嵌式的语言,是一种在服务器端执行的嵌入HTML文档的脚本语言,语言的风格有类似于C语言,被广泛地运用。
PHP语言解析
PHP 独特的语法混合了C、Java、Perl以及PHP自创的语法。它可以比CGI或者Perl更快速地执行动态网页。用PHP做出的动态页面与其他的编程语言相比,PHP是将程序嵌入到HTML文档中去执行,执行效率比完全生成HTML标记的CGI要高许多;PHP还可以执行编译后代码,编译可以达到加密和优化代码运行,使代码运行更快。
PHP的gzip压缩方法 ,为什么压缩了反而更慢了。尤其浏览器缓存js以后压缩网页以后,是减少网络传输时间、增加服务器和浏览器的CPU占用时间,总时间的影响要区别情况,如果你用高级电脑、慢速网络,那么肯定是压缩了的好,如果是高速网络、低配置电脑,那么肯定是不压缩的好。
是否采用压缩,一般是网站管理员决定,网站管理员看服务器的瓶颈是在流量上,还是CPU、内存占用上,根据情况决定是否压缩,以及压缩的程度。
另外,测试的网页大小可能不准确,许多网络工具是显示还原后的大小。
关于php压缩加密的介绍到此就结束了,不知道本篇文章是否对您有帮助呢?如果你还想了解更多此类信息,记得收藏关注本站,我们会不定期更新哦。