Page 1 of 1

titleColumn

PostPosted: Fri Jun 13, 2008 6:56 am
by fantomasdm
Hi I have 2 field name and surname, that is save in crypt format, is possible to
using my decrypt before using in titleColom like getTitle
Ex of my GetTitle:

Code: Select all
function getTitle(&$record)
   {
      return $this->gdecrypt($record->val('Nome')).' '.$this->gdecrypt($record->val('Cognome'));
   }



sorry for my bad english!

PostPosted: Mon Jun 16, 2008 2:25 pm
by shannah
Hi,

Unfortunately the titleColumn() method only provides SQL columns. If MySQL provides a function for decryption of your encryption technique then you can decrypt the columns - otherwise you won't be able to (short of writing a custom Mysql plugin).

You can see a list of mysql's built-in encryption/decryption functions at
http://dev.mysql.com/doc/refman/5.0/en/ ... tions.html

-Steve

PostPosted: Tue Jun 17, 2008 12:07 am
by fantomasdm
Hi I have use mysql function AES_DECRYPT / AES_CRYPT recreate in php code:

Code: Select all
class table_class  {

   var $td;
   var $iv;   
   function __construct(){
      $this->td = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_ECB, '');
      $this->iv = mcrypt_create_iv (mcrypt_enc_get_iv_size($this->td), MCRYPT_RAND);
   }

   function __destruct() {
      mcrypt_module_close($this->td);
   }

function gdecrypt($input)
{
   if( isset($_SESSION["PWDCRYPT"]) )
   {
      $key=$_SESSION["PWDCRYPT"];
      mcrypt_generic_init($this->td, $key, $this->iv);
      $encrypted_data = mdecrypt_generic ($this->td, $input);
      mcrypt_generic_deinit($this->td);
      return rtrim( $encrypted_data, ( ( ord(substr( $encrypted_data, strlen( $encrypted_data )-1, 1 )) >= 0 and ord(substr( $encrypted_data, strlen( $encrypted_data )-1, 1 ) ) <= 16 ) ? chr(ord(substr( $encrypted_data, strlen( $encrypted_data )-1, 1 ))): null) );
   }
   else
      return $input;
}

function gcrypt($input)
{
   if( !isset($_SESSION["PWDCRYPT"]) )
   {
      print "Occore prima inserire la password di criptazione";
      exit;
   }
   
   $key=$_SESSION["PWDCRYPT"];
   mcrypt_generic_init($this->td, $key, $this->iv);
   $val=str_pad($input, (16*(floor(strlen($input) / 16)+(strlen($input) % 16==0?2:1))), chr(16-(strlen($input) % 16)));
   $encrypted_data = mcrypt_generic($this->td, $val);
   mcrypt_generic_deinit($this->td);
   return    $encrypted_data;
}


}