Show
Ignore:
Timestamp:
11/30/07 01:35:15 (6 years ago)
Author:
takuya
Message:

/lang/php/Cache 暗号化してキャッシュをできるようにした

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/php/Cache/trunk/Handler/PlugIn/Crypt.php

    r2082 r2152  
    66 * @category    Cache 
    77 * @description crypt cache data to make difficult for reading data 
     8 * @see http://labs.unoh.net/2007/11/php_de_crypt.html 暗号化はこれを参考 
    89 */ 
    910 
    10 require_once 'Cache/Handler/PlugIn/Interface.php'; 
     11//require_once 'Cache/Handler/PlugIn/Interface.php'; 
    1112 
    12 class Cache_Handler_PlugIn_Crypt implements Cache_Handler_PlugIn_Interface { 
     13class Cache_Handler_PlugIn_Crypt/* implements Cache_Handler_PlugIn_Interface */{ 
    1314    /**  
    1415    * @access public 
     
    1718    { 
    1819        $this->crypt_keyword = $key; 
    19         $this->crypt_function_name = "undefined"; 
    2020    } 
    21      
    22     public function encode($data){ 
    23         return $data ; 
     21    private function initMcrypt(){ 
     22                /** 
     23                 * 初期化ベクトルを用意する 
     24                 * Windowsの場合、MCRYPT_DEV_URANDOMの代わりにMCRYPT_RANDを使用する 
     25                 */ 
     26                $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_BLOWFISH, MCRYPT_MODE_CBC), MCRYPT_DEV_URANDOM); 
     27                // 事前処理 
     28                $resource = mcrypt_module_open(MCRYPT_BLOWFISH, '',  MCRYPT_MODE_CBC, '');; 
    2429    } 
    25     public function decode($data){ 
    26         return $data ; 
     30    private function encode($data){ 
     31        return $encrypted_data = mcrypt_cbc(MCRYPT_BLOWFISH, $this->crypt_keyword, $data, MCRYPT_ENCRYPT, $this->iv); 
     32    } 
     33    private function decode($data){ 
     34        return $encrypted_data = mcrypt_cbc(MCRYPT_BLOWFISH, $this->crypt_keyword, $data, MCRYPT_DECRYPT, $this->iv); 
    2735    } 
    2836    /**  
     
    4856 
    4957} 
     58 
     59/////////test 
     60//$crypter = new Cache_Handler_PlugIn_Crypt("test"); 
     61//$data = "Googleのエンジニアってすごいよね"; 
     62//echo "------------"; 
     63//echo "\n"; 
     64//echo $data = $crypter->beforeWrite($data); 
     65//echo "\n"; 
     66//echo "------------"; 
     67//echo "\n"; 
     68//echo $data = $crypter->afterRead($data); 
     69//echo "\n";