php字符串加密解密算法二

        <pre class="prettyprint lang-php">&lt;?php

$str="这是一段需要加密的代码";

//混淆加密 function encode_str($str){ $str_arr=str_split($str); $str_encode=""; foreach($str_arr as $value){ $str_encode.=base64_encode($value); } return $str_encode; }

$encode_str=encode_str($str); echo $encode_str;

//解密函数 function decode_str($str){ $str_arr=str_split($str,4); $str_decode=""; foreach($str_arr as $value){ $str_decode.=base64_decode($value); } return $str_decode; }

$decode_str=decode_str($encode_str); echo $decode_str;

//结果 //JTIzJTJGJTIzJTJGJTIzJTJGJTIzJTJGJTIzJTJGJTIzJTJGJTIzJTJGJTIzJTJGJTIzJTJGJTIzJTJGJTIzJTJG //这是一段需要加密的代码