Search code examples
iossecurityencryptionios6

Password protect a folder in iPhone


We have a requirement to implement files protection in the app. Even though apple provides file protection attributes, we are doubtful about the behavior when iPhone is jail broken or device is not password protected. In order to implement this one idea is to encrypt all the files, file names, and such like. This is a long route. I m thinking instead of encrypting everything if possible add protection only at the top level. Say I have a folder named 'Top Folder' in documents folder where I store all the apps folders and files. With a password key can I add lock to only the top folder? How will it work?


Solution

  • No, you can't. A folder is only a part of file path, it cannot change (encrypt) data in files.

    On Mac, it would be possible to mount an encrypted filesystem to a folder, but no such functionality is possible on iOS.

    For encryption on iOS you have to encrypt/decrypt each file separately. Make sure the encryption keys are saved into the keychain and you encrypt/decrypt the files on the fly. Don't leave temporary decrypted files anywhere.