Hey there,
May I ask what's the reason you'd like to encrypt anything put in the database with algorithm that has deterministic decrypting algorithm?
The only thing that springs to my mind is handling database backups, is this the reason?
But, to answer your question: yes you can do that.
For the recordSet that is holding the field you want to encrypt, you need to add processing callback to it (unless you already have one you can use):
Utils_RecordBrowserCommon::register_processing_callback('<myRecordSet>', array('<MyModule>Common', 'processing_records'));
Then add the selected method, using this template:
public static function processing_records($values, $mode) {
if ($mode=='display') return array();
return $values;
}
In that method you will have to do all the encrypting as well as decrypting.
List of modes this method is called for:
[list:2k4u7vil]
[*:2k4u7vil]view - called when user enters "view record" screen,
return value is used as record[/*:m:2k4u7vil]
[*:2k4u7vil]adding - called when user enters "add new record" form,
return value is used as record[/*:m:2k4u7vil]
[*:2k4u7vil]add - called after submitting new record,
before the record was saved in databse so no ID yet,
return value is used as record[/*:m:2k4u7vil]
[*:2k4u7vil]added - called after record was saved in database, ID accessible,
return value is ignored[/*:m:2k4u7vil]
[*:2k4u7vil]editing - called when user enters "edit record" form,
return value is used as record [/*:m:2k4u7vil]
[*:2k4u7vil]edit - called after submitting record,
before the record was saved in databse,
return value is used as record [/*:m:2k4u7vil]
[*:2k4u7vil]delete - called after record was deleted from the system,
return value is ignored[/*:m:2k4u7vil]
[*:2k4u7vil]restore - called when record is restored,
return value is ignored[/*:m:2k4u7vil]
[*:2k4u7vil]cloning - called when user enters "add new record" via clone option, ID of the old record available,
return value is used as record[/*:m:2k4u7vil]
[*:2k4u7vil]cloned - called after saving a clone of a record, $values hold 2 records under keys 'original' and 'clone',
return value is ignored[/*:m:2k4u7vil]
[*:2k4u7vil]display - special mode, used when user views the record, returned value is used to assign additional values to template, useful for custom tpl's[/*:m:2k4u7vil][/list:u:2k4u7vil]
It's important to note that cloning and cloned are only addition to regular interface, when cloning a record,
both adding and cloning are triggered. Likewise, when they are saved, methods like add and added are also triggered.
Now, in your case, what you need is:
[list:2k4u7vil]
[*:2k4u7vil]add, edit - to encrypt[/*:m:2k4u7vil]
[*:2k4u7vil]view, cloning, editing - to decrypt[/*:m:2k4u7vil][/list:u:2k4u7vil]
Hope this helps,
Arek