Documentation TYPO3 par Ameos

adodb-encrypt-mcrypt.php

00001 <?php
00002 
00003 
00004 /*
00005 V4.80 8 Mar 2006  (c) 2000-2006 John Lim (jlim@natsoft.com.my). All rights reserved.
00006          Contributed by Ross Smith (adodb@netebb.com). 
00007   Released under both BSD license and Lesser GPL library license.
00008   Whenever there is any discrepancy between the two licenses,
00009   the BSD license will take precedence.
00010           Set tabs to 4 for best viewing.
00011 
00012 */
00013 
00014 if (!function_exists('mcrypt_encrypt')) {
00015         trigger_error('Mcrypt functions are not available', E_USER_ERROR);
00016         return 0;
00017 }
00018 
00021 class ADODB_Encrypt_MCrypt {
00024         var $_cipher;
00025 
00028         var $_mode;
00029 
00032         var $_source;
00033 
00036         function getCipher() {
00037                 return $this->_cipher;
00038         }
00039 
00042         function setCipher($cipher) {
00043                 $this->_cipher = $cipher;
00044         }
00045 
00048         function getMode() {
00049                 return $this->_mode;
00050         }
00051 
00054         function setMode($mode) {
00055                 $this->_mode = $mode;
00056         }
00057 
00060         function getSource() {
00061                 return $this->_source;
00062         }
00063 
00066         function setSource($source) {
00067                 $this->_source = $source;
00068         }
00069 
00072         function ADODB_Encrypt_MCrypt($cipher = null, $mode = null, $source = null) {
00073                 if (!$cipher) {
00074                         $cipher = MCRYPT_RIJNDAEL_256;
00075                 }
00076                 if (!$mode) {
00077                         $mode = MCRYPT_MODE_ECB;
00078                 }
00079                 if (!$source) {
00080                         $source = MCRYPT_RAND;
00081                 }
00082 
00083                 $this->_cipher = $cipher;
00084                 $this->_mode = $mode;
00085                 $this->_source = $source;
00086         }
00087 
00090         function write($data, $key) {
00091                 $iv_size = mcrypt_get_iv_size($this->_cipher, $this->_mode);
00092                 $iv = mcrypt_create_iv($iv_size, $this->_source);
00093                 return mcrypt_encrypt($this->_cipher, $key, $data, $this->_mode, $iv);
00094         }
00095 
00098         function read($data, $key) {
00099                 $iv_size = mcrypt_get_iv_size($this->_cipher, $this->_mode);
00100                 $iv = mcrypt_create_iv($iv_size, $this->_source);
00101                 $rv = mcrypt_decrypt($this->_cipher, $key, $data, $this->_mode, $iv);
00102                 return rtrim($rv, "\0");
00103         }
00104 
00105 }
00106 
00107 return 1;
00108 
00109 ?>


Généré par TYPO3 Ameos avec  doxygen 1.4.6