Changeset 1139

Show
Ignore:
Timestamp:
09/21/08 19:41:12 (2 months ago)
Author:
bermiferrer
Message:

Switching default encryption key to a md5 of current session name, which is varies from app to app

Adding a simple getter for un-nested settings Ak::getSetting()

Ak::getSettings('namespace')['varname'] == Ak::getSetting('namespace', 'varname')
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/Ak.php

    r980 r1139  
    11421142 
    11431143 
    1144     function encrypt($data, $key = 'Ak3los-m3D1a') 
    1145     { 
     1144    function encrypt($data, $key = null) 
     1145    { 
     1146        $key = empty($key) ? md5(AK_SESSION_NAME) : $key; 
    11461147        srand((double)microtime() *1000000); 
    11471148        $k2 = md5(rand(0, 32000)); 
     
    11671168    } 
    11681169 
    1169     function decrypt($encrypted_data, $key = 'Ak3los-m3D1a') 
    1170     { 
     1170    function decrypt($encrypted_data, $key = null) 
     1171    { 
     1172        $key = empty($key) ? md5(AK_SESSION_NAME) : $key; 
    11711173        $t = base64_decode($encrypted_data); 
    11721174        $k = md5($key); 
     
    11891191 
    11901192 
    1191     function blowfishEncrypt($data, $key = 'Ak3los-m3D1a'
    1192     { 
    1193         $key = substr($key,0,56); 
     1193    function blowfishEncrypt($data, $key = null
     1194    { 
     1195        $key = substr((empty($key) ? md5(AK_SESSION_NAME) : $key),0,56); 
    11941196        require_once(AK_CONTRIB_DIR.DS.'pear'.DS.'Crypt'.DS.'Blowfish.php'); 
    11951197        $Blowfish =& Ak::singleton('Crypt_Blowfish', $key); 
     
    11981200    } 
    11991201 
    1200     function blowfishDecrypt($encrypted_data, $key = 'Ak3los-m3D1a'
    1201     { 
    1202         $key = substr($key,0,56); 
     1202    function blowfishDecrypt($encrypted_data, $key = null
     1203    { 
     1204        $key = substr(empty($key) ? md5(AK_SESSION_NAME) : $key,0,56); 
    12031205        require_once(AK_CONTRIB_DIR.DS.'pear'.DS.'Crypt'.DS.'Blowfish.php'); 
    12041206        $Blowfish =& Ak::singleton('Crypt_Blowfish', $key); 
     
    19881990    } 
    19891991     
     1992    function getSetting($namespace, $variable, $default_value = null) 
     1993    { 
     1994        if($settings = Ak::getSettings($namespace)){ 
     1995            return isset($settings[$variable]) ? $settings[$variable] : $default_value; 
     1996        } 
     1997        return $default_value; 
     1998    } 
     1999     
    19902000    function _parseSettingsConstants($settingsStr) 
    19912001    {