I have the following the situation: I have some data structures which look like this:

    id: int
    name: BLOB
    password: VARCHAR(80)

There it is easy to store the encrypted fields in the MySQL database because I could simply use a field of type BLOB for the binary data.

But I also have some fields where the data is saved as a JSON Array. This implies that the content of the field looks like this:

{ "field1": "value1", "field2": true,"field3": "field3",...}

If I store it as a text, it works well. Now I am not sure how I should encrypt these fields. Should I encrypt the whole field and save it as a binary field (e.g. BLOB)? Or should I encrypt the data before (e.g. with PHP) and save it as a JSON array with some encrypted field values?

What is the best way to store such values also with respect to the web application performance? My idea would be to encrypt all fields which have the sensitive data (so in this example, the whole field which contains the JSON string) by using AES_ENCRYPT of MySQL. Is this a good way or would it be better to encrypt it beforehand using PHP?



You must log in to answer this question.

Browse other questions tagged .