/*
Copyright © 2020 , HuangDou , China.
292951110@qq.com
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
My Email help@usualtool.com
*/
/*
UTP(STR,UTP_TYPE,UTP_BASE64,UTP_MD5)
UTP_TYPE Input 0 or 1
UTP_BASE64 Input 0 or 1
UTP_MD5 Input 0 or 1
For example:
UTP("123456")
UTP("123456",1,0,1)
http://utp.usualtool.com
*/
Function UTP_StrSplit($key){
$search = array(
"0", "1", "2", "3", "4", "5",
"6", "7", "8", "9", "A", "B",
"C", "D", "E", "F", "G", "H",
"I", "J", "K", "L", "M", "N",
"O", "P", "Q", "R", "S", "T",
"U", "V", "W", "X", "Y", "Z",
"-");
$replace=array(
"0A1B", "1C2D", "2E3F", "3G4H", "4I5J", "5K6L",
"6M7N", "7O8P", "8Q9R", "9S0T", "A1B2", "B3C4",
"C5D6", "D7E8", "E9F0", "F1G2", "G3H4", "H5I6",
"I7J8", "J9K0", "K1L2", "L3M4", "M5N6", "N7O8",
"O9P0", "P1Q2", "Q3R4", "R5S6", "S7T8", "T9U0",
"U1V2", "V3W4", "W5X6", "X7Y8", "Y9Z0", "Z100",
"ABCD");
$arrs=str_split($key);
for($i=0;$i
$keynum=UTP_FindForeach($search,$arrs[$i]);
$strs[] =$replace[$keynum];
}
return $strs;
}
Function UTP_FindForeach($search,$findkey){
foreach ($search as $key => $v){
if($v==$findkey){
return $key;
}}
}
Function UTP($key,$utp_type=1,$utp_base64=1,$utp_md5=1){
if($utp_type==1){
$key=strtoupper(str_replace("_","-",$key));
$arr=UTP_StrSplit($key);
$strkey=implode("",$arr);
}else{
$strkey=$key;
}
if($utp_base64==1){
$strkey=base64_encode($strkey);
}
if($utp_md5==1){
$strkey=strtoupper(md5($strkey));
}
return $strkey;
}
一键复制
编辑
Web IDE
原始数据
按行查看
历史