0

I am working on an android project that I like to prevent users to get to content of my app database.

There are 3 ways I think, but I don't know witch one is the best and don't have any idea about how they should works.

My problem is I don't know which way is the best and how it works.

  1. encrypt all text and data to DB and decrypt when I want to use it!
  2. encrypt whole Database and decrypt when app needs it.
  3. uses 3rd party Libraries like SQLCipher.

2 Answers 2

2

I am working on an android project that I like to prevent users to get to content of my app database

If it is on the user's device, it is the user's database, not yours. It would only be your database if it is on your hardware.

My problem is I don't know which way is the best and how it works.

All are ineffective for trying to prevent the user from accessing the user's data.

Your database should be on internal storage, the default location for SQLite databases. Most users cannot access internal storage to get at the database. The only ones who can are the ones that root their devices. Anyone with the skills and interest to both root their device and try to get at the database in your app will have the skills and interest to either:

  1. Reverse-engineer your app to find your encryption algorithm and key, or

  2. Upload the database somewhere and convince somebody else to reverse-engineer your app to find your encryption algorithm and key

If you do not want the user to have access to the database, do not put it on their device. Access it via Web services from a server of yours.

Tools like SQLCipher for Android are for defending the user's data against attacks. They are not effective as a DRM solution.

Sign up to request clarification or add additional context in comments.

2 Comments

maybe you right but I can not put database on the web cause of my application structure . I need to make harder to reach to preloaded DB (not user DB!) although I know that may some professionals can reach to my DB with some tools or reserve engineering. but it's not matter. I just wanna make it harder to reach my data. so what is the easiest and best way?
@Kenji: Don't do anything. Just keep the database on internal storage, in its default location, like a regular database.
1

If you're going to encrypt the data at all, for goodness' sake, use a tested existing library instead of doing it badly yourself! For example, the author of SQLite itself sells an encryption extension (it's used in things like medical information systems), and there are a few other possible solutions too. (I googled for sqlite encryption and I'm sure you can too!)

However, be aware that holding the both encrypted data and the key to decrypt the data on the same non-trusted device is always likely to be troublesome; it's the DRM problem (i.e., you've put everything the user really needs to break things on the user's kit, and the user is relatively hostile). You should think about your application architecture; Android devices tend to be fairly well connected, so you can see if keeping the DB on a server somewhere that you control and only feeding little bits to the app (which it might cache, or not) is suitable instead.

2 Comments

I'm working on multimedia app that it should independence to Internet. cause my app should work even without net and it should responsible. I just wanna find some way to harden access to my preloaded data. I know that every way that without the Internet may hackable. so help me in this way.
@Kenji As I said, see (linked in answer, commercial, known to be good) is used already (though perhaps not in as hostile an environment) and I found some possible alternatives (whose quality I don't know) by just freaking Googling for the most obvious keywords I could think of. Come on! You can't get a much simpler search than that!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.