Click here to Skip to main content
15,884,986 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am using sqlite as my embedded database of choice, but because it is doesn't come encrypted, I wrote my own encryption code using openssl.

So I encrypt strings before logging to database and decrypt after reading from database.

I had to decrypt and save an array of c-style string into the data base, but when I attempted to read it, I found out that a particular string doesn't get decrypted.

Since decryption and saving to database in dove via a loop and since reading from database and decryption is also done via a loop I cannot imagine any reason why a particular string should not be decrypted.

I wish to know if these my experience ( with openssl) is not uncommon and also know if there is a possible way out?

The other thought on my mind this:
was there an interference in the database?
Posted
Updated 16-Dec-14 21:25pm
v2

1 solution

a reason for problems can be, that the encrypted "string" has a zero-terminator or other invalid char in it. You should store enrypted data as binary.

Be sure that is enough space for the saved data in your data structures. For debugging is an unecrypted shadow db fine.
 
Share this answer
 
Comments
Gbenbam 17-Dec-14 3:24am    
My problem storing as binary is that I won't be able '=' in a 'WHERE" clause, but would be compelled to use 'LIKE'.

I prefer "SELECT * FROM table WHERE Name = ' Sky' "

rather than

"SELECT * FROM table WHERE Name LIKE ' Sky' ".

By the way, how effective is the LIKE keyword in locating fields in a database?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900