I am using mysql-connector and I would like to store some data in MySQL database. I apply an EAS encryption using PyCrypto which results a byte string like the following one:
encrypted_data = b'\xd5\x9e\xea \x8d\xc4\xa6P\x93>\xda\x045\xd6\xfa8'
What is the most efficient way to store encrypted_data
in my database?
A thought is to convert the unicode byte to hex and store it as VARCHAR
. Though in that case I would need twice as much storage space.
Another thought would be to encrypt it inside MySQL. Though because I also use other encryption and hashing functions in python, I would prefer to do all the encryption stuff in python, so that code is more organized and readable.