从discuz里面拿来的东东[转phpx]
<?php 加解密函数 $encode = authocode ( '我要加密' , 'ENCODE' ); $decode = authocode ( '我要解密' , 'DECODE' ); $auth_key = 34577 ; //密钥 function authcode ( $string , $operation , $key = '' ) { $key = md5 ( $key ? $key : $GLOBALS [ 'auth_key' ]); $key_length = strlen ( $key ); $string = $operation == 'DECODE' ? base64_decode ( $string ) : substr ( md5 ( $string . $key ), 0 , 8 ). $string ; $string_length = strlen ( $string ); $rndkey = $box = array(); $result = '' ; for( $i = 0 ; $i <= 255 ; $i ++) { $rndkey [ $i ] = ord ( $key [ $i % $key_length ]); $box [ $i ] = $i ; } for( $j = $i = 0 ; $i < 256 ; $i ++)