PHP加密解密函数

2013年1月15日08:53:13PHP加密解密函数已关闭评论2,952 679字阅读2分15秒

以下为全部代码

< ?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; } ?>

本文章来自站群哥LsevenTT博客~转载请注明出处
PHP模拟百度URL加密解密算法 PHP相关

PHP模拟百度URL加密解密算法

PHP模拟百度URL加密解密算法的代码如下 <?php $time = time() . rand(1000, 9999); $data = "{$time}###https://www.lseventt.com"; // 被加密信息...
用PHP根据IP地址判断访问者所在省份,显示不同内容 SEO相关

用PHP根据IP地址判断访问者所在省份,显示不同内容

  在进行网站开发的过程中,有时候我们需要获取访问者的IP地址,根据访问者的IP地址,判断他所在的省份,然后呈现给访问者不同的内容。下面我们介绍一下使用淘宝的IP库来实现对指定省份显示指定内容的方法。 代码如下: <?php...
php根据ip段控制显示广告 PHP相关

php根据ip段控制显示广告

  以下代码是 PHP根据IP段控制显示广告   <?php function getIP() { $realip = ''; //设置默认值 if (isset($_SERVER)) { $realip = $_...