I want to encrypt an database using sqlcipher.
I have done with the integration os openssl and sqlcipher integration and the build works perfect.
But my issue is I am not able to encrypt my database. I don't know how to perform that activity or method to encrypt a database using sql cipher.
I read on the SQL Cipher but I am not able to understand the same process. I tried the code that is provided by them but not working .
EDIT: Can any one tell my how to set PRAGMA key for the same and then how to start with the encryption ? As only this part is remain for my encryption to get compl开发者_如何学运维eted.
Please help me out from this situation.
Thanks in advance
With SQLCipher make sure you have a brand new SQLite database. Trying to pragma the database with a key while it already has data for some reason just tries to decrypt it.
Here is some additional information on working with an existing SQLite database or here. In this example encrypted.db is that brand new database you create and pragma.
ATTACH DATABASE 'encrypted.db' AS encrypted KEY 'secret'; -- create a new encrypted database
CREATE TABLE encrypted.t1(a,b); -- recreate the schema in the new database (you can inspect all objects using SELECT * FROM sqlite_master)
INSERT INTO encrypted.t1 SELECT * FROM t1; -- copy data from the existing tables to the new tables in the encrypted database
DETACH DATABASE encrypted;
精彩评论