修改删除文章 |
一段php加密解密的代码-PHP教程,PHP应用<?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) { 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> "; print "encrypted text : $enc_text <br> "; print "decrypted text : $dec_text <br> "; ?> |
more本分类更多信息 电脑移动滑块解锁工具PHP网站源码保护神器ZendGuard5.5破解 zend_guard视频教程 使用ZendGuard-5_0_1备忘 用联想LenovoPortLocker给你的USB接口加上密… 用.htaccess控制服务器网站空间的默认编码★… 黑夜超级HTML网页加密器1.0 ASP删除记录同时删除图片代码(推荐使用亲测… 多个绑定多域名的ASP代码 两个基础的php代码加密压缩工具,在线版 |