加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

三个php加密解密算法

发布时间:2020-12-13 21:21:14 所属栏目:PHP教程 来源:网络整理
导读:三个功能强大的php加密解密函数 1 // 加密函数 2 function lock_url( $txt , $key ='www.fyunw.com' ) 3 { 4 $chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-=+" ; 5 $nh = rand (0,64 ); 6 $ch = $chars [ $nh ]; 7 $mdKey = m

三个功能强大的php加密解密函数

  1 //加密函数
  2 function lock_url($txt,$key='www.fyunw.com')
  3 {
  4     $chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-=+";
  5     $nh = rand(0,64);
  6     $ch = $chars[$nh];
  7     $mdKey = md5($key.$ch  8     substr($mdKey,1)">$nh%8,1)">$nh%8+7  9     $txt = base64_encode($txt 10     $tmp = '' 11     $i=0;$j=0;$k = 0 12     for ($i=0; $i<strlen($txt); $i++) {
 13         $k = $k == $mdKey) ? 0 : $k 14         $j = ($nh+strpos($chars,1)">$txt[$i])+ord($mdKey[$k++]))%64 15         $tmp .= $j 16     }
 17     return urlencode($ch.$tmp 18 }
 19 解密函数
 20 function unlock_url( 21  22     urldecode( 23      24     $txt[0 25      26      27      28      29      30     $j=0;  31      32          33         $j = $i])-$nh - $k++]);
 34         while ($j<0) $j+=64 35          36  37     base64_decode( 38  39 
 40 
 41 
 42 <?php
 43 function passport_encrypt($key = 'www.fyunw.com') 
 44 { 
 45     srand((double)microtime() * 1000000); 
 46     $encrypt_key = md5()); 
 47     $ctr = 0; 
 48      49     for($i = 0;$i < ) { 
 50     $ctr = $ctr == $encrypt_key) ? 0 : $ctr 51     $encrypt_key[$ctr].($i] ^ $ctr++]); 
 52     } 
 53     urlencode(base64_encode(passport_key($tmp,1)">$key))); 
 54 } 
 55 
 56 function passport_decrypt( 57  58     $txt = passport_key(base64_decode($txt)),1)"> 59      60      61     $md5 = $i]; 
 62     $txt[++$md5 63  64     return  65  66 
 67 function passport_key($encrypt_key 68  69      70      71      72     $i = 0;  73      74      75  76      77  78 ?>
 79  
 80 <?php 
 81 
 82 $txt = "1" 83 $key = "testkey" 84 $encrypt = passport_encrypt( 85 $decrypt = passport_decrypt($encrypt,1)"> 86 
 87 echo $encrypt."<br>" 88 $decrypt."<br>" 89 ?> 
 90 
 91 改进第一改加密之后的算法
 92 //加密函数
 93  94  95     $txt = $txt. 96      97      98      99     100     101     102     103     104     105         106         107         108 109     ));
110 111 112 113 114     115     116     117     118     119     120     121     122     123     124         125         126         127         128 129     trim($tmp),1)">130 }

?

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读