-1

I am looking for a way to store OpenSSL encrypted data in my MySQL database. When I store it, i can't retrieve the original string after, since it isn't storing the strings correctly.

Of course, I could save is base64 encoded and decrypt it later, which works like a charm. However, looking at efficiency I would like to know if there is a better way, since base64 encoding is eating disk space for storage.

Thanks for your advice

6
  • 4
    Instead of asking a generic question, show the current code of encrypting text, storing it, and trying to retrieve it, and describe the error in a detail. Commented Feb 5, 2017 at 22:12
  • And also the table definition. Commented Feb 5, 2017 at 22:32
  • OpenSSL is not an encryption method, it is a library that supports many encryption algorithms. Which one are you using. Also supply the code you have that is not working along with sample data/keys, modes, IV & etc. Commented Feb 5, 2017 at 22:45
  • 1
    And the result of encryption isn't a string, it is binary data. Commented Feb 6, 2017 at 1:26
  • Your problem appears to be getting binary data in and out of MySQL. See questions like Binary Data in MySQL and Calculating total data size of BLOB column in a table. Stop treating it like its a C-string. Commented Feb 6, 2017 at 22:32

1 Answer 1

3

Yes, you can store the encryption results as BINARY or VARBINARY, that way you don't loose the base64 overhead.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.