<?php
function base64_en($str){
$str = base64_encode($str);
$str .= randStr(5);
$str = base64_encode($str);
$str = randStr(3).$str;
return $str;
}
function randStr($len){
$str = "ABCDEFGHIJKLMNOPQRSTUVWSYZabcdefghijklmnopqrstuvwsyz0123456789";
return substr(str_shuffle($str),0,$len);
}
echo $s1 = base64_en("http://www.xinqdian.com");//加密后的串
function base64_de($str){
$len = strlen($str);
$str = substr($str,3,$len-2);
$str = base64_decode($str);
$str = substr($str,0,$len-5);
$str = base64_decode($str);
return $str;
}
echo "/n";
echo base64_de($s1);//解密后的串
?>
主要学习str_shuffle(var String);指定需要进行随机打乱的字符串对象