2 // Session Encryption by Ari Kuorikoski <ari.kuorikoski@finebyte.com>
4 function keyED($txt,$encrypt_key)
6 $encrypt_key = md5($encrypt_key);
9 for ($i=0;$i<strlen($txt);$i++){
10 if ($ctr==strlen($encrypt_key)) $ctr=0;
11 $tmp.= substr($txt,$i,1) ^ substr($encrypt_key,$ctr,1);
17 function Encrypt($txt,$key)
19 $encrypt_key = md5(rand(0,32000));
22 for ($i=0;$i<strlen($txt);$i++)
24 if ($ctr==strlen($encrypt_key)) $ctr=0;
25 $tmp.= substr($encrypt_key,$ctr,1) .
26 (substr($txt,$i,1) ^ substr($encrypt_key,$ctr,1));
29 return base64_encode($this->keyED($tmp,$key));
32 function Decrypt($txt,$key)
34 $txt = $this->keyED(base64_decode($txt),$key);
36 for ($i=0;$i<strlen($txt);$i++){
37 $md5 = substr($txt,$i,1);
39 $tmp.= (substr($txt,$i,1) ^ $md5);
49 $randnumber = rand(48,120);
51 while (($randnumber >= 58 && $randnumber <= 64) || ($randnumber >= 91 && $randnumber <= 96))
53 $randnumber = rand(48,120);
56 $randomPassword .= chr($randnumber);
58 return $randomPassword;