views:

502

answers:

3

I'm developing an iphone app that uses Core Data with a SQLite data store and lots of images in the resource bundle. I want a "simple" way to obfuscate the file structure of the SQLite database and the image files to prevent the casual hacker/unscrupulous developer from gaining access to them. When the app is deployed, the database file and image files would be obfuscated. Upon launching the app it would read in and un-obfuscate the database file, write the un-obfuscated version to the users "tmp" directory for use by core data, and read/un-obfuscate image files as needed.

I'd like to apply a simple algorithm to the files that would somehow scramble/manipulate the file data so that the sqlite database data isn't discernible when the db is opened in a text editor and so that neither is recognized by other applications (SQLite Manager, Photoshop, etc.)

It seems, from the information I've read, that I could use NSFileManager, NSKeyedArchiver, and NSData to accomplish this but I'm not sure how to proceed. Been developing software for many years but I'm new to everything CocoaTouch, Mac and iPhone. Also never had to secure/encrypt my data so this is new.

Any thoughts, suggestions, or links to solutions are appreciated.

+2  A: 

You can use gzip to zip up the file. Remove the extension and remove the header of the file, then it would be pretty tough to guess how to unencrypt it if anybody got ahold of the gzipped database.

When you want to read again, pre-pend the gzip header and decompress. gzip is available on the iPhone

coneybeare
Sounds like a good approach. The DB only has to be decrypted once per app run and gzip should be fairly quick on my 1MB database. As for the jpg's, I'm thinking I can remove or scramble the header in such a way that re-applying it at runtime would be fast. Never messed with a file's header or structure before so I guess I've got some learning to do :)Thanks for the feedback
Redrocks
Redrocks could you share more detail with me please ? [email protected] Thank you
fyasar
A: 

Redrocks,

did you able to resolve your question? how do you remove file header programmatically from xcoode.

Julie
A: 

Could someone please post sample code for doing this on iPhone?

Puneet