[ Index ]

PHP Cross Reference of vtigercrm-6.1.0

title

Body

[close]

/libraries/adodb/session/ -> crypt.inc.php (source)

   1  <?php
   2  //     Session Encryption by Ari Kuorikoski <[email protected]>
   3  class MD5Crypt{
   4  		function keyED($txt,$encrypt_key)
   5          {
   6                  $encrypt_key = md5($encrypt_key);
   7                  $ctr=0;
   8                  $tmp = "";
   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);
  12                          $ctr++;
  13                  }
  14                  return $tmp;
  15          }
  16  
  17  		function Encrypt($txt,$key)
  18          {
  19                  srand((double)microtime()*1000000);
  20                  $encrypt_key = md5(rand(0,32000));
  21                  $ctr=0;
  22                  $tmp = "";
  23                  for ($i=0;$i<strlen($txt);$i++)
  24                  {
  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));
  28                  $ctr++;
  29                  }
  30                  return base64_encode($this->keyED($tmp,$key));
  31          }
  32  
  33  		function Decrypt($txt,$key)
  34          {
  35                  $txt = $this->keyED(base64_decode($txt),$key);
  36                  $tmp = "";
  37                  for ($i=0;$i<strlen($txt);$i++){
  38                          $md5 = substr($txt,$i,1);
  39                          $i++;
  40                          $tmp.= (substr($txt,$i,1) ^ $md5);
  41                  }
  42                  return $tmp;
  43          }
  44  
  45  		function RandPass()
  46          {
  47                  $randomPassword = "";
  48                  srand((double)microtime()*1000000);
  49                  for($i=0;$i<8;$i++)
  50                  {
  51                          $randnumber = rand(48,120);
  52  
  53                          while (($randnumber >= 58 && $randnumber <= 64) || ($randnumber >= 91 && $randnumber <= 96))
  54                          {
  55                                  $randnumber = rand(48,120);
  56                          }
  57  
  58                          $randomPassword .= chr($randnumber);
  59                  }
  60                  return $randomPassword;
  61          }
  62  
  63  }
  64  
  65  
  66  class SHA1Crypt{
  67  		function keyED($txt,$encrypt_key)
  68          {
  69  
  70                  $encrypt_key = sha1($encrypt_key);
  71                  $ctr=0;
  72                  $tmp = "";
  73  
  74                  for ($i=0;$i<strlen($txt);$i++){
  75                          if ($ctr==strlen($encrypt_key)) $ctr=0;
  76                          $tmp.= substr($txt,$i,1) ^ substr($encrypt_key,$ctr,1);
  77                          $ctr++;
  78                  }
  79                  return $tmp;
  80  
  81          }
  82  
  83  		function Encrypt($txt,$key)
  84          {
  85  
  86                  srand((double)microtime()*1000000);
  87                  $encrypt_key = sha1(rand(0,32000));
  88                  $ctr=0;
  89                  $tmp = "";
  90  
  91                  for ($i=0;$i<strlen($txt);$i++)
  92  
  93                  {
  94  
  95                  if ($ctr==strlen($encrypt_key)) $ctr=0;
  96  
  97                  $tmp.= substr($encrypt_key,$ctr,1) .
  98  
  99                  (substr($txt,$i,1) ^ substr($encrypt_key,$ctr,1));
 100  
 101                  $ctr++;
 102  
 103                  }
 104  
 105                  return base64_encode($this->keyED($tmp,$key));
 106  
 107          }
 108  
 109  
 110  
 111  		function Decrypt($txt,$key)
 112          {
 113  
 114                  $txt = $this->keyED(base64_decode($txt),$key);
 115  
 116                  $tmp = "";
 117  
 118                  for ($i=0;$i<strlen($txt);$i++){
 119  
 120                          $sha1 = substr($txt,$i,1);
 121  
 122                          $i++;
 123  
 124                          $tmp.= (substr($txt,$i,1) ^ $sha1);
 125  
 126                  }
 127  
 128                  return $tmp;
 129          }
 130  
 131  
 132  
 133  		function RandPass()
 134          {
 135                  $randomPassword = "";
 136                  srand((double)microtime()*1000000);
 137  
 138                  for($i=0;$i<8;$i++)
 139                  {
 140  
 141                          $randnumber = rand(48,120);
 142  
 143                          while (($randnumber >= 58 && $randnumber <= 64) || ($randnumber >= 91 && $randnumber <= 96))
 144                          {
 145                                  $randnumber = rand(48,120);
 146                          }
 147  
 148                          $randomPassword .= chr($randnumber);
 149                  }
 150  
 151                  return $randomPassword;
 152  
 153          }
 154  
 155  
 156  
 157  }


Generated: Fri Nov 28 20:08:37 2014 Cross-referenced by PHPXref 0.7.1