龙空技术网

PHP方式实现字符串混淆,随机位置插入随机字符

迷神笔记 323

前言:

如今看官们对“php字符串排序”都比较关怀,咱们都需要剖析一些“php字符串排序”的相关资讯。那么小编同时在网络上搜集了一些有关“php字符串排序””的相关文章,希望大家能喜欢,看官们快快来了解一下吧!

图/文:迷神

在程序开发的时候,因为某些特别目的,我们希望字符串文本之类的,能随机插入一些随机特殊字符,这样可以绕过某些检测字符串内容。具体其他的功能,自由发挥啦。

下面分享一个,基于PHP的方式,实现字符串混淆随机位置插入随机字符:

代码如下:

<?phpheader("Content-Type:text/html;charset=utf-8");$ad=["↑","↓","←","→","↖","↗","↘","↙","↔","↕","➻","➼","➽","➸","➳","➺","➻","➴","➵","➶","➷","➹","▶","►","▷","◁"];$times = 3; //关键字出现频率$str = "阿克苏绝对法拉克世界疯了阿拉山口地方就看到las决哦iasfls.sdmflaskdf洛杉矶的法律卡死噢iuoi020990拉开时间的发生了疯狂";$strlen = mb_strlen($str, "utf-8");//随机生成插入位置,根据$times决定插入频率for ( $i = 0; $i < $times; $i ++ ) {    $arr[] = mt_rand(0, $strlen);}$arr = array_unique($arr); //过滤数组重复元素sort($arr); //对数组重新排序,按照值由小到大//开始替换$i = 0;$str_new = "";foreach( $arr as $v ) {    $keyword = $ad[rand(0,count($ad))];    $str_new .= mb_substr($str, $i, $v - $i, "utf-8") . $keyword;    $i = $v;}$str_new .= mb_substr($str, $i, $strlen - $i, "utf-8");echo($str_new);?>

运行结果如下:

标签: #php字符串排序 #php混淆解密在线工具 #随机字符串php