Zikula 1.0.1
[ class tree: Zikula 1.0.1 ] [ index: Zikula 1.0.1 ] [ all elements ]

Source for file adodb-encrypt-mcrypt.php

Documentation is available at adodb-encrypt-mcrypt.php

  1. <?php
  2.  
  3.  
  4. /*
  5. V4.97 22 Jan 2008  (c) 2000-2008 John Lim (jlim#natsoft.com.my). All rights reserved.
  6.          Contributed by Ross Smith (adodb@netebb.com). 
  7.   Released under both BSD license and Lesser GPL library license.
  8.   Whenever there is any discrepancy between the two licenses,
  9.   the BSD license will take precedence.
  10.       Set tabs to 4 for best viewing.
  11.  
  12. */
  13.  
  14. if (!function_exists('mcrypt_encrypt')) {
  15.     trigger_error('Mcrypt functions are not available'E_USER_ERROR);
  16.     return 0;
  17. }
  18.  
  19. /**
  20.  */
  21.     /**
  22.      */
  23.     var $_cipher;
  24.  
  25.     /**
  26.      */
  27.     var $_mode;
  28.  
  29.     /**
  30.      */
  31.     var $_source;
  32.  
  33.     /**
  34.      */
  35.     function getCipher({
  36.         return $this->_cipher;
  37.     }
  38.  
  39.     /**
  40.      */
  41.     function setCipher($cipher{
  42.         $this->_cipher = $cipher;
  43.     }
  44.  
  45.     /**
  46.      */
  47.     function getMode({
  48.         return $this->_mode;
  49.     }
  50.  
  51.     /**
  52.      */
  53.     function setMode($mode{
  54.         $this->_mode = $mode;
  55.     }
  56.  
  57.     /**
  58.      */
  59.     function getSource({
  60.         return $this->_source;
  61.     }
  62.  
  63.     /**
  64.      */
  65.     function setSource($source{
  66.         $this->_source = $source;
  67.     }
  68.  
  69.     /**
  70.      */
  71.     function ADODB_Encrypt_MCrypt($cipher null$mode null$source null{
  72.         if (!$cipher{
  73.             $cipher MCRYPT_RIJNDAEL_256;
  74.         }
  75.         if (!$mode{
  76.             $mode MCRYPT_MODE_ECB;
  77.         }
  78.         if (!$source{
  79.             $source MCRYPT_RAND;
  80.         }
  81.  
  82.         $this->_cipher = $cipher;
  83.         $this->_mode = $mode;
  84.         $this->_source = $source;
  85.     }
  86.  
  87.     /**
  88.      */
  89.     function write($data$key{
  90.         $iv_size mcrypt_get_iv_size($this->_cipher$this->_mode);
  91.         $iv mcrypt_create_iv($iv_size$this->_source);
  92.         return mcrypt_encrypt($this->_cipher$key$data$this->_mode$iv);
  93.     }
  94.  
  95.     /**
  96.      */
  97.     function read($data$key{
  98.         $iv_size mcrypt_get_iv_size($this->_cipher$this->_mode);
  99.         $iv mcrypt_create_iv($iv_size$this->_source);
  100.         $rv mcrypt_decrypt($this->_cipher$key$data$this->_mode$iv);
  101.         return rtrim($rv"\0");
  102.     }
  103.  
  104. }
  105.  
  106. return 1;
  107.  
  108. ?>

Documentation generated on Fri, 18 Jul 2008 21:39:25 +0200 by phpDocumentor 1.4.1