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; 
    } 
    ?>
  • 相关阅读:
    杨辉三角1
    岛屿与周长
    什么是计算机语言
    爬虫爬取视图片
    爬虫爬取文字生成词云
    英文词频统计
    回溯法~0-1背包的实现
    java Swing图形化界面
    棋盘覆盖
    敏捷软件开发 10~12章
  • 原文地址:https://www.cnblogs.com/ghjbk/p/7519827.html
Copyright © 2011-2022 走看看