Cordova-sqlite-storage: How to encrypt and decrypt the sqlite database using sqlcipher for cordova app?

Created on 11 Aug 2016  路  4Comments  路  Source: storesafe/cordova-sqlite-storage

Hi,
I have created my sample ionic project. In that I have to use sqlcipher to encrypt and decrypt my sqlite database.

For that,
I have installed sqlcipher adapter using, cordova plugin add https://github.com/litehelpers/Cordova-sqlcipher-adapter

Then,
I have created my database with key also as db = $cordovaSQLite.openDB({name:"sqlcipher.db", key: "test", location:1});
I am new to sqlcipher. Can anyone tell me further what I have to do for encryption and decrytion?
I have refered this, https://www.zetetic.net/sqlcipher/documentation/ link. But, I unable to find the solution for cordova.

Thanks.

question

Most helpful comment

@brodybits , Can you please tell me how to use that key to encrypt and decrypt the sqlcipher database?

All 4 comments

I highly recommend that you get the password key from some form of user input. Otherwise that is exactly how you should use encrypted databases with the Cordova-sqlcipher-adapter. With SQLCipher, you just open the database with the password key and it takes care of the encryption and decryption. There is no way to read the data if you do not open an encrypted database with the correct key.

Please confirm if this answers your question or not.

@Chris, Thanks for your replay. My question is how to do encryption and decryption using sqlcipher?? In my sample ionic app, I have just added sqlcipher adapter & I have created db. Can you help me regarding this?

My question is how to do encryption and decryption using sqlcipher??

Use a key when you open a database with SQLCipher and it will encrypt and decrypt your data. As a test you can try to open the same database with a different key and it should not be possible to read the data. You can also try to open the encrypted database with no password key and again it should not be possible to read the data.

@brodybits , Can you please tell me how to use that key to encrypt and decrypt the sqlcipher database?

Was this page helpful?
0 / 5 - 0 ratings