I'm trying to encrypt values to be stored in a database for later retrieval and decryption. The simple solution appears to be to use accessor/mutator for the table.
protected function _setFirstName($first_name)
{
return Security::encrypt($first_name, $this->key);
}
protected function _getFirstName($first_name)
{
if ($this->_properties) {
return Security::decrypt($first_name, $this->key);
}
}
What I've noticed is that while the mutator does the conversion, before saving the accessor is reverting it, saving the value as the unencrytped original and not the encrypted value.
How do I get it to save the encrypted value?