简体   繁体   中英

What datatype should I use to store long encrypted messages on MySQL?

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!

Yes, it will be better if you can store the values in the "TEXT" data type. For more details, please read this http://dev.mysql.com/doc/refman/5.5/en/blob.html .

Regarding knowledge of storage requirements, you can read thiss one http://dev.mysql.com/doc/refman/5.5/en/storage-requirements.html .

Hope it helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM