00001 <?php
00002
00003 class MD5Crypt{
00004 function keyED($txt,$encrypt_key)
00005 {
00006 $encrypt_key = md5($encrypt_key);
00007 $ctr=0;
00008 $tmp = "";
00009 for ($i=0;$i<strlen($txt);$i++){
00010 if ($ctr==strlen($encrypt_key)) $ctr=0;
00011 $tmp.= substr($txt,$i,1) ^ substr($encrypt_key,$ctr,1);
00012 $ctr++;
00013 }
00014 return $tmp;
00015 }
00016
00017 function Encrypt($txt,$key)
00018 {
00019 srand((double)microtime()*1000000);
00020 $encrypt_key = md5(rand(0,32000));
00021 $ctr=0;
00022 $tmp = "";
00023 for ($i=0;$i<strlen($txt);$i++)
00024 {
00025 if ($ctr==strlen($encrypt_key)) $ctr=0;
00026 $tmp.= substr($encrypt_key,$ctr,1) .
00027 (substr($txt,$i,1) ^ substr($encrypt_key,$ctr,1));
00028 $ctr++;
00029 }
00030 return base64_encode($this->keyED($tmp,$key));
00031 }
00032
00033 function Decrypt($txt,$key)
00034 {
00035 $txt = $this->keyED(base64_decode($txt),$key);
00036 $tmp = "";
00037 for ($i=0;$i<strlen($txt);$i++){
00038 $md5 = substr($txt,$i,1);
00039 $i++;
00040 $tmp.= (substr($txt,$i,1) ^ $md5);
00041 }
00042 return $tmp;
00043 }
00044
00045 function RandPass()
00046 {
00047 $randomPassword = "";
00048 srand((double)microtime()*1000000);
00049 for($i=0;$i<8;$i++)
00050 {
00051 $randnumber = rand(48,120);
00052
00053 while (($randnumber >= 58 && $randnumber <= 64) || ($randnumber >= 91 && $randnumber <= 96))
00054 {
00055 $randnumber = rand(48,120);
00056 }
00057
00058 $randomPassword .= chr($randnumber);
00059 }
00060 return $randomPassword;
00061 }
00062
00063 }
00064
00065
00066 class SHA1Crypt{
00067
00068 function keyED($txt,$encrypt_key)
00069 {
00070
00071 $encrypt_key = sha1($encrypt_key);
00072 $ctr=0;
00073 $tmp = "";
00074
00075 for ($i=0;$i<strlen($txt);$i++){
00076 if ($ctr==strlen($encrypt_key)) $ctr=0;
00077 $tmp.= substr($txt,$i,1) ^ substr($encrypt_key,$ctr,1);
00078 $ctr++;
00079 }
00080 return $tmp;
00081
00082 }
00083
00084
00085
00086 function Encrypt($txt,$key)
00087 {
00088
00089 srand((double)microtime()*1000000);
00090 $encrypt_key = sha1(rand(0,32000));
00091 $ctr=0;
00092 $tmp = "";
00093
00094 for ($i=0;$i<strlen($txt);$i++)
00095
00096 {
00097
00098 if ($ctr==strlen($encrypt_key)) $ctr=0;
00099
00100 $tmp.= substr($encrypt_key,$ctr,1) .
00101
00102 (substr($txt,$i,1) ^ substr($encrypt_key,$ctr,1));
00103
00104 $ctr++;
00105
00106 }
00107
00108 return base64_encode($this->keyED($tmp,$key));
00109
00110 }
00111
00112
00113
00114 function Decrypt($txt,$key)
00115 {
00116
00117 $txt = $this->keyED(base64_decode($txt),$key);
00118
00119 $tmp = "";
00120
00121 for ($i=0;$i<strlen($txt);$i++){
00122
00123 $sha1 = substr($txt,$i,1);
00124
00125 $i++;
00126
00127 $tmp.= (substr($txt,$i,1) ^ $sha1);
00128
00129 }
00130
00131 return $tmp;
00132 }
00133
00134
00135
00136 function RandPass()
00137 {
00138 $randomPassword = "";
00139 srand((double)microtime()*1000000);
00140
00141 for($i=0;$i<8;$i++)
00142 {
00143
00144 $randnumber = rand(48,120);
00145
00146 while (($randnumber >= 58 && $randnumber <= 64) || ($randnumber >= 91 && $randnumber <= 96))
00147 {
00148 $randnumber = rand(48,120);
00149 }
00150
00151 $randomPassword .= chr($randnumber);
00152 }
00153
00154 return $randomPassword;
00155
00156 }
00157
00158
00159
00160 }
00161 ?>