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 srand((double)microtime()*1000000);
20 $encrypt_key = md5(rand(0,32000));
23 for ($i=0;$i<strlen($txt);$i++
)
25 if ($ctr==strlen($encrypt_key)) $ctr=0;
26 $tmp.= substr($encrypt_key,$ctr,1) .
27 (substr($txt,$i,1) ^
substr($encrypt_key,$ctr,1));
30 return base64_encode($this->keyED($tmp,$key));
33 function Decrypt($txt,$key)
35 $txt = $this->keyED(base64_decode($txt),$key);
37 for ($i=0;$i<strlen($txt);$i++
){
38 $md5 = substr($txt,$i,1);
40 $tmp.= (substr($txt,$i,1) ^
$md5);
48 srand((double)microtime()*1000000);
51 $randnumber = rand(48,120);
53 while (($randnumber >= 58 && $randnumber <= 64) ||
($randnumber >= 91 && $randnumber <= 96))
55 $randnumber = rand(48,120);
58 $randomPassword .= chr($randnumber);
60 return $randomPassword;
68 function keyED($txt,$encrypt_key)
71 $encrypt_key = sha1($encrypt_key);
75 for ($i=0;$i<strlen($txt);$i++
){
76 if ($ctr==strlen($encrypt_key)) $ctr=0;
77 $tmp.= substr($txt,$i,1) ^
substr($encrypt_key,$ctr,1);
86 function Encrypt($txt,$key)
89 srand((double)microtime()*1000000);
90 $encrypt_key = sha1(rand(0,32000));
94 for ($i=0;$i<strlen($txt);$i++
)
98 if ($ctr==strlen($encrypt_key)) $ctr=0;
100 $tmp.= substr($encrypt_key,$ctr,1) .
102 (substr($txt,$i,1) ^
substr($encrypt_key,$ctr,1));
108 return base64_encode($this->keyED($tmp,$key));
114 function Decrypt($txt,$key)
117 $txt = $this->keyED(base64_decode($txt),$key);
121 for ($i=0;$i<strlen($txt);$i++
){
123 $sha1 = substr($txt,$i,1);
127 $tmp.= (substr($txt,$i,1) ^
$sha1);
138 $randomPassword = "";
139 srand((double)microtime()*1000000);
144 $randnumber = rand(48,120);
146 while (($randnumber >= 58 && $randnumber <= 64) ||
($randnumber >= 91 && $randnumber <= 96))
148 $randnumber = rand(48,120);
151 $randomPassword .= chr($randnumber);
154 return $randomPassword;