View Full Version : base64 encoding content before insert

09-21-2011, 03:59 PM
Can anyone see a problem with base64 encoding any strings that get inserted into a DB and decoding them on select?

Instead of worrying about strip_slashes, mysql_real_escape_string or magic_quotes, just base64 decode the string.

Apart from, perhaps, speed of encoding/decoding, can anyone see any issues with this?

09-21-2011, 04:38 PM
Well it would make it harder to search the text in the database unless you are using MySQL 5.6+ which has built in functions for base 64. But all that decoding to search for something (or just in general) could actually be a pretty significant performance drain.

09-21-2011, 04:42 PM
I wondered that myself, but couldn't the search be done on the encoded text (considering it is a linear encoding algorithm and the same unencoded string encodes to the same encoded string)?