PHP的加密和解密程序方法
来源:互联网 发布:充电监控软件 编辑:程序博客网 时间:2024/04/26 00:31
<script type="text/javascript"><!--google_ad_client = "pub-4490194096475053";/* 内容页,300x250,第一屏 */google_ad_slot = "3685991503";google_ad_width = 300;google_ad_height = 250;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
- <?php
- $key = "This is supposed to be a secret key !!!";
- function keyED($txt,$encrypt_key)
- {
- $encrypt_key = md5($encrypt_key);
- $ctr=0;
- $tmp = "";
- for ($i=0;$i<strlen($txt);$i++)
- {
- if ($ctr==strlen($encrypt_key)) $ctr=0;
- $tmp.= substr($txt,$i,1) ^ substr($encrypt_key,$ctr,1);
- $ctr++;
- }
- return $tmp;
- }
- function encrypt($txt,$key) <script type="text/javascript"><!--google_ad_client = "pub-4490194096475053";/* 728x90, 创建于 08-12-8 */google_ad_slot = "0403648181";google_ad_width = 728;google_ad_height = 90;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
- {
- srand((double)microtime()*1000000);
- $encrypt_key = md5(rand(0,32000));
- $ctr=0;
- $tmp = "";
- for ($i=0;$i<strlen($txt);$i++)
- {
- if ($ctr==strlen($encrypt_key)) $ctr=0;
- $tmp.= substr($encrypt_key,$ctr,1) .
- (substr($txt,$i,1) ^ substr($encrypt_key,$ctr,1));
- $ctr++;
- }
- return keyED($tmp,$key);
- }
- function decrypt($txt,$key)
- {
- $txt = keyED($txt,$key);
- $tmp = "";
- for ($i=0;$i<strlen($txt);$i++)
- {
- $md5 = substr($txt,$i,1);
- $i++;
- $tmp.= (substr($txt,$i,1) ^ $md5);
- }
- return $tmp;
- }
- $string = "Hello World !!!";
- // encrypt $string, and store it in $enc_text
- $enc_text = encrypt($string,$key);
- // decrypt the encrypted text $enc_text, and store it in $dec_text
- $dec_text = decrypt($enc_text,$key);
- print "Original text : $string <Br>/n";
- print "Encrypted text : $enc_text <Br>/n";
- print "Decrypted text : $dec_text <Br>/n";
- ?>
- PHP的加密和解密程序方法
- 又一个php加密和解密的方法
- php 加密和解密方法
- PHP和Javascript的xxtea字符串加密/解密方法
- DES加密和解密PHP,Java,ObjectC统一的方法
- php在线加密的解密程序
- PHP程序的AES加密解密算法
- php 简单的解密和加密
- php的加密解密
- php实现和c#一致的DES加密解密 (php中调用方法)
- php openssl加密解密方法
- php 自定义加密、解密方法
- php openssl加密解密方法
- 常用的加密和解密方法
- 使用DES加密和解密的方法
- 简单PHP对称加密解密方法、具有时效性的php加密解密函数
- 非常不错的php加密和php解密函数
- php mcrypt启用、加密以及解密的方法介绍
- exit(0),exit(1),exit-1)
- 用select控制 DIV 中的内容
- 遍历form表单下的所有控件
- AJAX核心对象-- XMLHttpRequest 对象使用详解 (二)
- 捕捉回车事件
- PHP的加密和解密程序方法
- 华为招聘新法则:大招毕业生和控制社会招聘
- Grid Application Systems Design
- 深入理解Servlet/JSP之“Servlet和JSP原理”
- CCDA Official Exam Certification Guide
- CCNP BSCI Official Exam Certification Guide
- VS2005开发Window Mobile SmartPhone智能手机软件
- 刷新页面的几种方法
- Cisco Express Forwarding (Networking Technology)