简体   繁体   中英

swift - Encrypt files of document folder without device lock [on hold]

I want to apply encryption on files available in the document folder of my app. I know I can apply encryption provided by iOS, but I think, correct me if I am wrong, that only works when user enables passcode on their device. Is there any way I can use iOS disk encryption without device passcode. If not what are other options available without a performance compromise. I know I can apply manual AES encryption on each file but that's going to be a big performance hit as in my app there's going to be n number of files and encrypting all the files and decrypting every time user tries to access that will be an overkill.

You can indeed use NSFileProtection to encrypt the files in your app whenever the device is lock. However, if you choose to use your own encryption, there will be a performance hit. For example, Realm estimates this to be 10% slower .

Yet, before rushing into implementation, take a moment to access your need. Is your app a banking or military app? Do you have strict security requirements in terms of data protection? Why do you need to protect these files?

If you choose to go down that path, I encourage you to read this blog post by Cossack Labs, where they explain how they implemented end-to-end encryption to Bear app. It might give you some insight.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM