php tcp utp链接,UTP.PHP

该博客介绍了UTP编码函数的详细实现,包括`UTP_StrSplit`、`UTP_FindForeach`和`UTP`等关键函数。`UTP`函数支持对输入字符串进行不同类型的编码,如类型转换、Base64编码和MD5加密。此外,还提供了一个使用示例,展示了如何使用这些函数对字符串进行操作。
摘要由CSDN通过智能技术生成

/*

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

原始数据

按行查看

历史

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值