zoukankan      html  css  js  c++  java
  • PHP的MD5加密解密函数

    function encode($code,$seed = "qh8.net", $safe = false){
            if ($safe) $code = base64_encode(strrev(str_rot13($code)));
            $c_l = strlen($code);
            $s_m = md5($seed);
            $s_l = strlen($m);
            $a=0;
            while ($a <$c_l){
                $str .= sprintf ("%'02s",@base_convert(ord($code{$a})+ord($s_m{$s_l % $a+1}),10,32));
                $a++;
            }
            return $str;//wordwrap($str, 80, "n", true)
        }
       
       
        function decode($code, $seed = 'qh8.net', $safe = false){
            //$code = preg_replace("'[ rnt]+'", '', $code);
            preg_match_all("/.{2}/", $code, $arr);
            $arr = $arr[0];
            $s_m = md5($seed);
            $s_l = strlen($m);
            $a = 0;
            foreach ($arr as $value){
                $str .= @chr(@base_convert($value,32,10)-ord($s_m{$s_l % $a+1}));
                $a++;
            }
            if ($safe) $str = str_rot13(strrev(base64_decode($str)));
            return $str;
        }


  • 相关阅读:
    网络流24题-分配问题
    网络流24题-圆桌问题
    git ssh
    SQL Server 添加说明 语句
    问题思路
    数据库事务和锁
    Castle Windsor
    Flask学习笔记11之特殊的装饰器
    python中的"环绕通知"
    Flask学习笔记10之flash
  • 原文地址:https://www.cnblogs.com/cnsec/p/11515929.html
Copyright © 2011-2022 走看看