在程序开拓的时候,由于某些特殊目的,我们希望字符串文本之类的,能随机插入一些随机分外字符,这样可以绕过某些检测字符串内容。详细其他的功能,自由发挥啦。
下面分享一个,基于PHP的办法,实现字符串稠浊随机位置插入随机字符:
代码如下:
<?phpheader(34;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);?>
运行结果如下: