how can i encrypt my .db file in Xcode - iphone

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.

Related

how to deal with encrypted sqlite database in 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.

Any FREE SQLite Manager for MAC OS X?

I am learning Core Data for iPhone application. I defined .xcdatamodel. But I have the following questions:
Is it possible to make .sqlite file
from the .xcdatamodel file ?
If not, what is the correct
procedure to prepare .sqlite ?
If it is necessary to use external
tool, is there any FREE tool to make
.sqlite ?
Thanks.
Your questions 1 & 2 have already been answered but here's a comprehensive overview for Q3:
http://www.barefeetware.com/sqlite/compare/?ch
I personally use a (free) Firefox add-on called SQLite Manager - you can download it from here https://addons.mozilla.org/en-US/firefox/addon/sqlite-manager/
Is it possible to make .sqlite file
from the .xcdatamodel file ?
Well, when you create a Core Data stack and set your store to an SQLite store, the persistent store coordinator will create a .sqlite file configured for the model attached to the store.
If not, what is the correct procedure
to prepare .sqlite ?
Before iOS 3.0, you couldn't use Core Data so there were several libraries out there for using SQLite. However, I don't think any of them have been updated because there is not much point when using Core Data.
If it is necessary to use external
tool, is there any FREE tool to make
.sqlite ?
SQLite comes standard as part of MacOS X so you can use the command line or scripting languages like Ruby, Python, Perl (also standard) to create any SQLite database you want.
But honestly, I wouldn't bother. Unless your app's data is very simple and largely static, you will end up reinventing the wheel and effectively reproducing most of Core Data just to interface SQLite with the rest of the app.
Core Data's SQLite structure really isn't designed to be handled by anything other than Core Data. Even if you have your persistent store use the SQLite data format, if you open it in a generic SQLite tool you're going to get a cryptic mash of nothing-you-can-reliably-mess-with.
I'm guessing your goal is to have pre-populated data in your database? The right way to do that is to write some “importer” code that reads in whatever existing data you have and creates objects in the persistent store corresponding to those. Keep a copy of that persistent store—maybe in your app bundle, to be copied out to a temporary directory for writing—and you've got yourself a starting data set.

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.

Implementing data encryption in iPhone applications

I need to implement data encryption in my app locally, as well as transfer data over the network, after encrypting it.
Can anyone help me by guiding me to good documentation or resources to acheive this? I have looked upon Apple's cryptoClient application but it's too cryptic(contains Bonjour sharing etc. which I don't need).
Use ZipArchive to encrypt the files (check the documentation, there is a way to zip the data with a password) and since you are gonna transfer the data over the network you should make it as small as possible by zipping it.
This is a great tutorial on using ZipArchive:
http://icodeblog.com/2010/04/12/creating-a-document-centric-iphoneipad-application-with-own-file-format-using-ziparchive/
You can have a look at SQLCipher to encrypt sqlite database, which can store your data locally and to transfer over internet you can simply use HTTPS.