I have a model that encrypts several attributes, before saving them to a MySQL table. After find(), it decrypts them.
This is all done with the encryptByKey and decryptByKey methods of the yii\base\Security class in Yii2, using a predefined encryptionKey constant, and all works fine.
All values are saved in BLOB fields in the table. Now for the next challenge.
I want to be able to search within this columns. I know MySQL has encryption and decryption functions, but can’t seem to get it to work.
Its an encryption novice replying while you wanted king to reply.
As per my understanding, encrypted columns are not meant to be searched and you can make another index column only for searching without exposing the contents of the encrypted column.
Obviously I must read more about encryption methods (not now though).
I guess the encryption creates something like multiple exclusive "factors" representing the unencrypted data. Decryptable using the encryptionkey constant.