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

    [PHP]代码

    <?php 
    //blog.qita.in
    function passport_encrypt($txt, $key) { 
    srand((double)microtime() * 1000000); 
    $encrypt_key = md5(rand(0, 32000)); 
    $ctr = 0; 
    $tmp = ''; 
    for($i = 0;$i < strlen($txt); $i++) { 
    $ctr = $ctr == strlen($encrypt_key) ? 0 : $ctr; 
    $tmp .= $encrypt_key[$ctr].($txt[$i] ^ $encrypt_key[$ctr++]); 
    } 
    return base64_encode(passport_key($tmp, $key)); 
    }
    function passport_decrypt($txt, $key) { 
    $txt = passport_key(base64_decode($txt), $key); 
    $tmp = ''; 
    for($i = 0;$i < strlen($txt); $i++) { 
    $md5 = $txt[$i]; 
    $tmp .= $txt[++$i] ^ $md5; 
    } 
    return $tmp; 
    }
    function passport_key($txt, $encrypt_key) { 
    $encrypt_key = md5($encrypt_key); 
    $ctr = 0; 
    $tmp = ''; 
    for($i = 0; $i < strlen($txt); $i++) { 
    $ctr = $ctr == strlen($encrypt_key) ? 0 : $ctr; 
    $tmp .= $txt[$i] ^ $encrypt_key[$ctr++]; 
    } 
    return $tmp; 
    } 
    ?>
  • 相关阅读:
    12-29 批量删除
    12-29 注册审核
    12-25造数据库面向对象
    12-23 会话保持
    2016-12-19 php修改数据库数据
    12-18数据访问
    12-16php测试题
    1027 制作表格
    1027 超链接
    1027 HTML
  • 原文地址:https://www.cnblogs.com/ghjbk/p/7519827.html
Copyright © 2011-2022 走看看