迅速学会PHP加密解密技巧
闲话少说,先将它们打包成一个文件就叫fun.php吧
< ?php
function passport_encrypt($txt, $key) {
srand((double)microtime() * 1000000);
$encrypt_key = md5(rand(0, 32000));
$ctr = 0;
$tmp = '';
for($i = 0;$i < strlen($txt); $i++) {
$ctr = $ctr == strlen($encrypt_key) ? 0 : $ctr;
$tmp .= $encrypt_key[$ctr].($txt[$i]
^ $encrypt_key[$ctr++]);
}
return base64_encode(passport_key($tmp, $key));
}
function passport_decrypt($txt, $key) {
$txt = passport_key(base64_decode($txt), $key);
$tmp = '';
for($i = 0;$i < strlen($txt); $i++) {
$md5 = $txt[$i];
$tmp .= $txt[++$i] ^ $md5;
}
return $tmp;
}
function passport_key($txt, $encrypt_key) {
$encrypt_key = md5($encrypt_key);
$ctr = 0;
$tmp = '';
for($i = 0; $i < strlen($txt); $i++) {
$ctr = $ctr == strlen($encrypt_key) ? 0 : $ctr;
$tmp .= $txt[$i] ^ $encrypt_key[$ctr++];
}
return $tmp;
}
?>
以下是一些示例…加深对这三个PHP加密解密函数的理解…
//string.php < ?php include “fun.php”; $txt = “This is a test”; $key = “testkey”; $encrypt = passport_encrypt($txt,$key); $decrypt = passport_decrypt($encrypt,$key); echo $txt.”< br>< hr>”;
相关文档:
rsync 是一款高效的远程数据备份和镜象工具,可快速地同步多台主机间的文件,其具有如下特性:
支持链接、所有者、组信息以及权限信息的拷贝;
通过远程 shell(ssh, rsh)进行传输;
无须特殊权限即可安装使用;
流水线式文件传输模式,文件传输效率高;
支持匿名操作;
通过远程 shell 方式:
rsync [OPTION] [USE ......
步骤一:搭建环境
1,首先查看你的php扩展目录下是否有php_gettext.dll这个
文件,如果没有,这就需要你
下载一个或是从其他地方拷贝一个,然后放到php扩展目录。
2,打开php.ini,查
找”;extension=php_gettext.dll“ ,然后去除注释,重启apache。
步骤二:原理讲解
假如你的没
有国际化的程序里有这样 ......
(1) autoload机制概述
在使用PHP的OO模式开发系统时,通常大家习惯上将每个类的实现都存放在一个单独的文件里,这样会很容易实现对类进行复用,同时将来维护时也很便利。这也是OO设计的基本思想之一。在PHP5之前,如果需要使用一个类,只需要直接使用include/require将其包含进来即可。下面是一个实际的例子:
CODE:
/* ......
windows下开发php扩展网上很多资料都说需要Cygwin,其实完全可以不必安装该东东。没错,是可以在linux下生成骨架后拷到windos下来用,但是,如果没有linux环境呢?什么,装虚拟机?我晕,你咋又绕回去了- -! 除了编译外,shell环境主要就是为了生成扩展的骨架,其实骨架已经在php源码包中了了,我们只需要把相关名字替换一 ......
xml_parse解析xml文件时候,
很有可能不仅仅调用一次character_handler。
所以在获得xml节点的文本信息的时候,要用连接运算".="。
参考 http://jp2.php.net/manual/ro/function.xml-set-character-data-handler.php
ken at positive-edge dot com
30-Jan-2002
01:20
the function handler is called ......