Find action in crypted fields

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

Find action in crypted fields

Postby fantomasdm » Fri Jun 27, 2008 1:51 am

HI, I have a fields that ware crypted by function _displau, pushValue, pullValue, now I need to search value that was insert in encrypt mode, is possible to use a trigger like beforeFind for encrypt data to send to find engine?

Sorry for my English!!! Thancks for help!!!
fantomasdm
 
Posts: 114
Joined: Thu Mar 13, 2008 2:35 pm

Postby shannah » Mon Jun 30, 2008 9:06 am

You can implement the __serialize() method which is used to serialize the value of a field when it is being placed in an SQL query. The only thing you need to make sure is that you can tell if the value has already been encrypted so that it doesn't encrypt it twice.

e.g.

Code: Select all
function foo__serialize($value){
    if ( isAlreadyEncrypted($value) ) return $value;
    else return myEncryptionFunc($value);
}

Where the function isAlreadyEncrypted() can tell you whether a value has been encrypted already, and the myEncryptionFunc() encrypts the value.


-Steve
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby fantomasdm » Tue Jul 01, 2008 12:28 am

Hi I need to serialize only for find action, so I have add this code:

Code: Select all
function cognome__serialize($value)
   {
      //echo "azione".$_REQUEST['-action']."#";
      //return $this->gcrypt($value);
      if ($_REQUEST['-action']=="edit" || $_REQUEST['-action']=="new")
         return $value;
      else
         return $this->gcrypt($value);
   }

It's seem to me that its works!!
Thanks for help and for your patience!!!!
fantomasdm
 
Posts: 114
Joined: Thu Mar 13, 2008 2:35 pm

Postby shannah » Wed Jul 02, 2008 9:38 am

It would be better if you could find a way to tell if the value is encrypted without relying on the current action, because there may be other actions and instances where you save the record (e.g. the update/copy record action, or other cutsom actions).

-Steve
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 7 guests

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