使用 UIFileSharingEnabled 密码保护/锁定 sqlite 数据库不被在应用程序外部打开?
我在 iPhone 应用程序中设置了 UIFileSharingEnabled。我想这样做,以便用户可以访问由核心数据管理的database.sqlite 文件。这样,他们就可以将其拖放到多部 iPhone/touch/iPad 之间,并将其用作穷人的同步。
但是,我不希望他们打开 sqlite 文件并 a) 修改数据库和 b) 对我的数据模型进行逆向工程。
有谁知道如何使用密码保护或锁定数据库,以便用户无法在应用程序外部打开它?
I have UIFileSharingEnabled set in my iPhone app. I wanted to do this so the user could have access to the database.sqlite file managed by Core Data. This way, they could drag and drop it between their multiple iPhones/touchs/iPads and use it as sort of an poor-man's sync.
However, I don't want them opening the sqlite file and a) mucking around the database and b) reverse engineering my data model.
Does anyone know a way to password protect or lock out the database so that the user can't open it outside the app?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以过滤掉对应用程序可见的文件,但不能过滤掉对 iTunes FS 可见的文件。
当我将 iTunes 文件共享支持添加到我的应用程序时,我编写了代码以静默方式将 DB 文件移动到 iTFS 不可见的新目录。下面的代码将 sqlite DB 文件从 Documents 目录移动到 iTFS 不可见的 Application Support 目录。
You can filter out the files that you make visible to the app, but not what is visible to iTunes FS.
When I added my iTunes File Sharing support to my app, I wrote code to silently move the DB file to a new directory that would not be visible to iTFS. The code below moves the sqlite DB file from the Documents directory to the Application Support directory which is not visible to iTFS.
也许您可以使用一些 ZIP 或 RAR 库,因为它们支持密码保护。然后,当您的应用程序移至后台时压缩 sqlite 文件,并在应用程序移至前台时解压缩。
Maybe you can use some ZIP or RAR library as they have support for password protection. Then zip the sqlite file when your app moves to background and unzip when comes to foreground.