I am investigating encrypting and decrypting my data in my database using CakePHP. How do you guys secure your data in your database?
A possible approach would be; 'saving' my (unencrypted) data via the model, which should encrypt specific data and save it into the database. When retrieving data via the model, it should decrypt the data and give it back to me.
Another option would be; implementing the encrypt
and decrypt
functions in the specific entity (using the getters and setters). However, searching on specific fields would be harder (because you want to keep your code DRY)
I know that encrypt
and decrypt
functions are available in Cake: https://book.cakephp.org/3.0/en/core-libraries/security.html
TLDR; How do I implement encryption and decryption the right way in CakePHP when I want to store my data secure?