titleColumn

A place for users and developers of the Xataface to discuss and receive support.

titleColumn

Postby fantomasdm » Fri Jun 13, 2008 6:56 am

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!
fantomasdm
 
Posts: 114
Joined: Thu Mar 13, 2008 2:35 pm

Postby shannah » Mon Jun 16, 2008 2:25 pm

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
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby fantomasdm » Tue Jun 17, 2008 12:07 am

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;
}


}
fantomasdm
 
Posts: 114
Joined: Thu Mar 13, 2008 2:35 pm


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 34 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved