php base64 編碼與解碼實例代碼
更新時間:2017年03月21日 10:18:18 作者:微幫幫
這篇文章主要介紹了php base64 編碼與解碼實例代碼的相關(guān)資料,需要的朋友可以參考下
php base64 編碼與解碼詳解
1.自定義規(guī)則方式編碼和解碼
實例
public function test_changinttoStr () { $intvalue1 = 1232344234; $intStr = ''; $str = "Y 9 L F k g y 5 R o v i x I 1 a O f 8 U h d s 3 r 4 D M p l Q Z J X P q e b E 0 W S j B n 7 w V z m N 2 G c 6 T H C A K u t"; $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.利用系統(tǒng)函數(shù)完成base64位的編碼和解碼
實例代碼:
public function testArray(){ // $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); }
感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
相關(guān)文章
php 大數(shù)據(jù)量及海量數(shù)據(jù)處理算法總結(jié)
大數(shù)據(jù)量的問題是很多面試筆試中經(jīng)常出現(xiàn)的問題,比如baidu google 騰訊 這樣的一些涉及到海量數(shù)據(jù)的公司經(jīng)常會問到2011-05-05PHP封裝的svn類使用內(nèi)置svn函數(shù)實現(xiàn)根據(jù)svn版本號導(dǎo)出相關(guān)文件示例
這篇文章主要介紹了PHP封裝的svn類使用內(nèi)置svn函數(shù)實現(xiàn)根據(jù)svn版本號導(dǎo)出相關(guān)文件,結(jié)合實例形式分析了php封裝的svn操作類與根據(jù)版本導(dǎo)出相關(guān)版本文件操作技巧,需要的朋友可以參考下2018-06-06PhpSpreadsheet設(shè)置單元格常用操作匯總
這篇文章主要介紹了PhpSpreadsheet設(shè)置單元格常用操作匯總,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下2020-11-11