- chr: documentation ( source)
- dechex: documentation ( source)
- hexdec: documentation ( source)
- str_pad: documentation ( source)
- str_split: documentation ( source)
- ord: documentation ( source)
<?php
echo $a=fzz_encode('http://blog.csdn.net/fzzwake/article/details/3785884?$#%%');
echo fzz_decode($a);
function fzz_encode($str) {
for($i=0;$i<strlen($str);$i++) {
$restr .= str_pad(dechex(ord($str{$i})),2,0,STR_PAD_LEFT);
}
return $restr;
}
function fzz_decode($str) {
$arr = str_split($str,2);
foreach ((array)$arr as $val) {
$restr .= chr(hexdec($val));
}
return $restr;
}