0

I'd like to use Core Data in my application, which contains sensitive information. So I would like to protect it from being accessed, even on phones which aren't locked.

Right now I'm encrypting the sqlite, sqlite-shm and sqlite-wal files in didEnterBackground: and decrypt them again in applicationWillEnterForeground:. It works as expected, but I don't know if that's the best way to do. E.g. if my application crashes, it won't encrypt the files.

Encrypting and decrypting single entries/columns in the database isn't the best option as well, because then I can't use predicates, right?

So what's the 'state of the art'? Is there a way to have the sqlite file only decrypted whenever the app is opened?

As the app is >= iOS 7, wWould be checking the encrypted/decrypted state periodically (while the app is in the background) an option? But if the user turns of background refresh I'm lost again...

swalkner
  • 16,679
  • 31
  • 123
  • 210

1 Answers1

1

If NSFileProtectionComplete isn't enough for you (Data Protection / NSFileProtectionComplete - successfully supported through entitlements.plist? goes into pretty good detail), then SQLCipher looks promising.

Community
  • 1
  • 1
Hal Mueller
  • 7,019
  • 2
  • 24
  • 42