I am working on an web application that will allow users to write messages and store them on a database to be accessed by some other users who are meant to. I have a user authentication system ready and also the encryption system works fine but I am confused about the datatype to use for storing the messages.
I am using a MySQL database with PHP to store the values encrypted using openssl AES-256
. The cipher texts produced are binary, and I need to store them on the database.
Now I can try using base64
to encode the binary strings a, but it increases the size of the data from 33 to 100%.
The messages could be long and I want my database no get screwed up with performance or storage capabilities. I also have to stick with MySQL for some reasons.
So should I use BLOB or TEXT? Which one will be more efficient in terms of performance? And also, what should be the type-like TINYTEXT, TEXT, MEDIUMTEXT, or LONGTEXT
or the the corresponding types for BLOB
s?
I want to make sure both faster performance and storage capabilities are fulfilled.
Thanks for the help!