how to deal with encrypted sqlite database in iPhone? - iphone

I have an encrypted version of an sqlite database
and also I have the KEY
but honestly I have no idea about using it or how to get the data from the encrypted database?
I guess the solution somewhere in the open function?
if(sqlite3_open([_dbPath UTF8String],&database)==SQLITE_OK);
Can anybody help me??

The core SQLite database implementation does not itself provide encryption support. There does however exist a number of extensions for adding encryption to SQLite. Some of these encrypt the entire database file while some other only encrypt the contents of the tables.
These extensions are for the most part not compatible, so you will most likely have to use the same extension on the iPhone as the one used on C#. And if you're lucky that extension is also supported on iOS.

Related

how can i encrypt my .db file in Xcode

Hello,
Can anyone tell me how to encrypt the .db or sqlite file in Xcode so as to prevent others person to access the data of .db file ?
I have given the ipa file for testing and the tester is able to access all data in .db file.
So can anyone please suggest any mechanism to prevent users to see the data in .db file ?
Thanks.
The best way as per my research & understanding is to use the OS level encryption, by that way you reduce the chances of getting into runtime DB issues.
I recommend you have a look at this article which explains/talks more about it in detail.
Core Data and Enterprise iPhone Applications – Protecting Your Data
Maybe you can use this project to encrypt your database with Core Data
Or you can use this API with this wrapper to encrypt your .db
check out http://sqlcipher.net
Full Database Encryption for SQLite
SQLCipher is an open source extension to SQLite that provides transparent 256-bit AES encryption of database files.

decryption using sqlcipher in iphone

Okey, so i am studying sqlcipher and preparing a document on it. so far study shows that how to encrypt database, i could not find how to decrypt database. Like that i have few more questions.
I found that you can not perform coredata operation on encrypted database.so
1) Can i run a sql query on encrypted database.
2) so if i have to perform a coredata operation, so i have to decrypt the database.
3) and last but not least, how to do decryption using sqlcipher.
Please answer if these questions make sense.
Thanks
Yes, you can perform a SQL query on an encrypted database, however the pages within a SQLCipher enabled SQLite database need to be decrypted prior to retrieving the unencrypted data. In order to access an SQLCipher encrypted database, you need issue either the PRAGMA key command, or programmatically call sqlite3_key. Additional documentation can be found here, along with the mailing list here.

Import from SQLite manager into a file

I'm using SQLite version 2.8.17 - 3.3.7 / PHP version 5.2.17
I've created a db with a few tables and want to export it into .db or .sqlite file but it gives me dump text.
I'd like to use this db in iPhone, but I'm currently stuck with app to manage sqlite databases.
Would appreciate any help.
Also I've tried sqlite manager for firefox, but its ugly:)
Please, tell me about an app to create sqlite databases and populate them with info for future use in iPhone.
Have a go with Lita
I use Navicat for SQLite for this. Im my opinion it's a great tool with a nice GUI. You can import/export in several formats. Well, it's not free, but there is a trial.
I have successfully implemented what you're talking about by dumping the database (serverside) into an XML file, which the iPhone can pull via a simple http request, and then convert into it's own data structures. Reading XML on the iPhone.
Originally, I tried doing it how you're thinking, it was just too complicated and error-prone to justify.

iPhone:Create Password Protect SQLite database

i am able to create sqlite database using firefox addon and use database in iPhone. Now I want to give the the password to database and used it in my iPhone application. i tried a lot on google to search the proper way yo create password protected database but still no success.
anybody have idea that how can create the password protected sqlite database and how can we use it in iPhone
Try SQLiteEncrypt.The SQLiteEncrypt is an AES encryption embedded SQLite database engine through which you can encrypt and decrypt your SQLite database file. When set a password key into your database file, content is no longer stored in cleartext, so that we achieve the purpose of data protection.
But it is not free.
Note: But IT is not for iOS (thanks brad to pointed it out).
*Edit***
For iPhone you can use SQLCIPHER which is an open source full database encryption for sqlite.
Unfortunately, there is no free solution for doing that.
There are some commercial applications, which allows sqlite database encryption.
Also, there is virtual filesystem support in SQLite, where you can change calls which reads/writes data to SQLite database, however that will require some coding.

sqlite data file encrypt

I hope to encrypt sqlite file which store my app data.
Is there a simple way to do this?
Welcome any comment.
Thanks
interdev
There are a few commercial options which provide add-ons to SQLite for encryption. The most likely candidate is:
The SQLite Encryption Extension which is developed by the original author of SQLite. This is distributed as source and can be compiled for any platform. In this way, you could compile your own embedded version of SQLite instead of using the system one. It provides both RC4 and AES encryption.
There are two other products, but appear to require Windows:
SQLiteCrypt - AES encryption
SQLite-Encrypt - AES encryption
Both seem to have very similar features, but it isn't clear if you get the source to recompile on iOS.