PageRenderTime 46ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/concrete/libraries/3rdparty/adodb/session/old/crypt.inc.php

https://bitbucket.org/selfeky/xclusivescardwebsite
PHP | 64 lines | 57 code | 6 blank | 1 comment | 10 complexity | 5a4e4fde0da690423376a99610929101 MD5 | raw file
  1. <?php
  2. // Session Encryption by Ari Kuorikoski <ari.kuorikoski@finebyte.com>
  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. function Encrypt($txt,$key)
  17. {
  18. srand((double)microtime()*1000000);
  19. $encrypt_key = md5(rand(0,32000));
  20. $ctr=0;
  21. $tmp = "";
  22. for ($i=0;$i<strlen($txt);$i++)
  23. {
  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));
  27. $ctr++;
  28. }
  29. return base64_encode($this->keyED($tmp,$key));
  30. }
  31. function Decrypt($txt,$key)
  32. {
  33. $txt = $this->keyED(base64_decode($txt),$key);
  34. $tmp = "";
  35. for ($i=0;$i<strlen($txt);$i++){
  36. $md5 = substr($txt,$i,1);
  37. $i++;
  38. $tmp.= (substr($txt,$i,1) ^ $md5);
  39. }
  40. return $tmp;
  41. }
  42. function RandPass()
  43. {
  44. $randomPassword = "";
  45. srand((double)microtime()*1000000);
  46. for($i=0;$i<8;$i++)
  47. {
  48. $randnumber = rand(48,120);
  49. while (($randnumber >= 58 && $randnumber <= 64) || ($randnumber >= 91 && $randnumber <= 96))
  50. {
  51. $randnumber = rand(48,120);
  52. }
  53. $randomPassword .= chr($randnumber);
  54. }
  55. return $randomPassword;
  56. }
  57. }
  58. ?>