• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

一个简单的php加密解密函数(动态加密)_php技巧

php 搞代码 3年前 (2022-01-26) 28次浏览 已收录 0个评论
function encode_pass($tex,$key,$type="encode"){<BR>    $chrArr=array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',<BR>                  'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',<BR>                  '0','1','2','3','4','5','6','7','8','9');<BR>    if($type=="decode"){<BR>        if(strlen($tex)<14)return false;<BR>        $verity_str=substr($tex, 0,8);<BR>        $tex=substr($tex, 8);<BR>        if($verity_str!=substr(md5($tex),0,8)){<BR>            //完整性验证失败<BR>            return false;<BR>        }    <BR>    }<BR>    $key_b=$type=="decode"?substr($tex,0,6):$chrArr[rand()%62].$chrArr[rand()%62].$chrArr[rand()%62].$chrArr[rand()%62].$chrArr[rand()%62].$chrArr[rand()%62];<BR>    $rand_key=$key_b.$key;<BR>    $rand_key=md5($rand_key);<BR>    $tex=$type=="decode"?base64_decode(substr($tex, 6)):$tex;<BR>    $texlen=strlen($tex);<BR>    $reslutstr="";<BR>    for($i=0;$i<$texlen;$i++){<BR>        $reslutstr.=$tex{$i}^$rand_key{$i%32};<BR>    }<BR>    if($type!="decode"){<BR>        $reslutstr=trim($key_b.base64_encode($reslutstr),"==");<BR>        $reslutstr=substr(md5($reslutstr), 0,8).$reslutstr;<BR>    }<BR>    return $reslutstr;<BR>}<BR>$psa=encode_pass("phpcode","taintainxousad");<BR>echo $psa<strong style="color:transparent">本&文来源gao@daima#com搞(%代@#码网@</strong><textarea>搞gaodaima代码</textarea>;<BR>echo encode_pass($psa,"taintainxousad",'decode');<BR>

搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:一个简单的php加密解密函数(动态加密)_php技巧
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址