5 function Encrypt($str, $key = "your_key") {
6 return enc_dec_wkey("encrypt", $str, $key);
8 function Decrypt($str, $key = "your_key") {
9 return enc_dec_wkey("decrypt", $str, $key);
11 function enc_dec_wkey($mode, $str, $key='') {
12 if($key==='') return $str;
13 if($mode=== "decrypt") $str = base64_decode($str);
14 $key = str_replace(chr(32),'',$key);
15 if(strlen($key) < 8) exit('key error');
16 $kl = strlen($key) < 32 ?
strlen($key) : 32;
18 for ($i = 0; $i < $kl; $i++
) $k[$i] = ord($key{$i}) & 0x1F;
20 for($i = 0; $i < strlen($str); $i++
) {
22 $str{$i} = $e & 0xE0 ?
chr($e^
$k[$j]): chr($e);
24 $j = $j == $kl ?
0 : $j;
26 if($mode == "encrypt")
27 return base64_encode($str);