php base64 编码与解码实例代码
phpbase64编码与解码详解
1.自定义规则方式编码和解码
实例
publicfunctiontest_changinttoStr(){
$intvalue1=1232344234;
$intStr='';
$str="Y9LFkgy5RovixI1aOf8Uhds3r4DMplQZJXPqebE0WSjBn7wVzmN2Gc6THCAKut";
$seq=explode("",$str);
$intvalue=$intvalue1;
while($intvalue>=62){
#code...
$intStr=($seq[$intvalue%62]).$intStr;
$intvalue=(int)($intvalue/62);
}
$intStr=($seq[$intvalue]).$intStr;
echo($intStr);
$keySeq=array_flip($seq);
$length=strlen($intStr);
$value=0;
for($i=$length-1;$i>=0;$i--){
$t=$keySeq[$intStr[$i]];
$s=($length-$i)-1;
$m=(pow(62,$s)*$t);
$value+=$m;
}
echo$value;
}
2.利用系统函数完成base64位的编码和解码
实例代码:
publicfunctiontestArray(){
//$str['a']='sdfsdf';
//$str['d']='sdafsdf';
//$newStr=$this->modifyArray($str);
$value=gmp_strval(gmp_init('234234234234',10),62);
$newValue=gmp_strval(gmp_init($value,62),10);
}
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
热门推荐
10 参加儿子大学祝福语简短
11 早日回国祝福语简短英语
12 结婚转账祝福语高级简短
13 毕业男生聚餐祝福语简短
14 宝宝周岁敬酒祝福语简短
15 周日徒步祝福语大全简短
16 出嫁条幅伴娘祝福语简短
17 圣诞祝福语简短小学
18 婆婆生娃祝福语简短