function mcrypt_code($str,$type=''){ //普通的des加密解密
global $des_key;
$str = trim($str);
$return = '';
if($str){
$td = mcrypt_module_open('des', '', 'ecb', '');
$key = substr($des_key, 0, mcrypt_enc_get_key_size($td));
$iv_size = mcrypt_enc_get_iv_size($td);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
if(mcrypt_generic_init($td, $key, $iv) != -1){
if($type==''){
$encode = mcrypt_generic($td, $str);
mcrypt_generic_deinit($td);
$return = base64_encode($encode);
}elseif($type=='decode'){
$str = base64_decode($str);
$decode = mdecrypt_generic($td, $str);
$return = $decode;
}
mcrypt_generic_deinit($td);
mcrypt_module_close($td);
}
if(empty($return)) $return = 0;
}
else $return = 0;
return trim($return);
}
function call_time() //毫秒
{
$m_time = explode(' ',microtime());
$call_time = $m_time[1].($m_time[0]*1000);
$call_time = explode('.',$call_time);
return $call_time[0];
}
function decode_qq($str=''){ //3des解碼uid
global $des_key;
$num = strlen($str);
for($i=0; $i<$num; $i+=2){
$decode_str.=chr(base_convert(substr($str,$i,2),16,10));
}
$decode = mcrypt_decrypt(MCRYPT_3DES, $des_key, $decode_str, MCRYPT_MODE_ECB, '');
return $decode;
}