Find action in crypted fields
Posted:
Fri Jun 27, 2008 1:51 am
by fantomasdm
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!!!
Posted:
Mon Jun 30, 2008 9:06 am
by shannah
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
Posted:
Tue Jul 01, 2008 12:28 am
by fantomasdm
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!!!!
Posted:
Wed Jul 02, 2008 9:38 am
by shannah
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