[英]How can I protect my files in app's document directory from reading by external tools(iFunbox/iTools etc)
I want to develop an photo protected app. 我想开发一个受照片保护的应用程序。 When first launch, it forces user to input an password and every time back to the app, user must input the same password again. 首次启动时,它会强制用户输入密码,并且每次返回应用程序时,用户都必须再次输入相同的密码。 User takes photo in my app and I store the photo in app's document directory. 用户在我的应用程序中拍照,我将照片存储在应用程序的文档目录中。
It works well but someone can access content in the app's document through external tools like iFunbox, they can export the photos. 它运作良好,但有人可以通过iFunbox等外部工具访问应用程序文档中的内容,他们可以导出照片。 So my app is not safe enough. 因此我的应用程序不够安全。 I have considered that I can use ZipArchive
to compress photos with an password when save photos and uncompress photos when using want to see the photos, but compressing and uncompressing will cost much time and battery, I think it is not an good idea. 我考虑过可以在保存照片时使用ZipArchive
来使用密码压缩照片,而在想查看照片时可以使用解压缩照片,但是压缩和解压缩会花费很多时间和电池,我认为这不是一个好主意。
Can someone give me some suggestion? 有人可以给我一些建议吗? Thanks in advance. 提前致谢。
You can use the NSData
writeToFile:options:error:
with the option NSDataWritingFileProtectionComplete
which will write it encrypted. 您可以将NSData
writeToFile:options:error:
与选项NSDataWritingFileProtectionComplete
,以加密方式将其写入。 This will only protect the files when the iOS device is locked. 仅在iOS设备锁定时,这将保护文件。
Alternatively you can encrypt the file yourself with CommonCrypto AES and save the key in the keychain. 或者,您可以使用CommonCrypto AES自己加密文件,然后将密钥保存在钥匙串中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.