ios - 适用于 iOS 的 Magical Record 和 SQLCipher - NSPersistentStore 创建返回 nil

标签 ios encryption sqlcipher

我正在尝试将 SQLCipher 添加到一个使用 Magical Record 库来加密数据库的 iOS 项目。还使用加密核心数据项目中的 EncryptedStore 类:https://github.com/project-imas/encrypted-core-data .

已按照帖子 iOS Magical Record & SQLCipher 中的说明进行操作

我已经将方法 - (NSPersistentStore *) MR_addSqliteStoreNamed:(id)storeFileName withOptions:(__autoreleasing NSDictionary *)options 编辑为..

[coordinator
                                    addPersistentStoreWithType:EncryptedStoreType
                                    configuration:nil
                                    URL:databaseURL
                                    options:options
                                    error:&error];

有选项:

NSDictionary *options = @{
                            EncryptedStorePassphraseKey : @"the_password",
                            NSMigratePersistentStoresAutomaticallyOption : @YES,
                            NSInferMappingModelAutomaticallyOption : @YES
                            };

我遇到一个问题,如果使用 EncryptedStoreType 类型,则不会创建生成的 NSPersistentStore* 对象(返回 nil)。返回的错误码也是nil。

使用的 SQLCipher 库是商业 iOS 版本,其中已经包含 openSSL。 SQLCipher 的集成似乎没问题,在加密核心数据项目中测试时,我能够很好地使用加密数据库。

可能不太可能,但是在将 SQLCipher 与 Magical Record 集成时,有没有人遇到过类似的问题 - 任何建议表示赞赏。

提前致谢 2J

最佳答案

我今天遇到了这个问题,在使用日志语句对 EncryptedStore.m 进行了大量探索之后,我发现它无法创建新数据库,因为我添加了一个以索引作为属性名称的实体。

原来你不能使用索引作为属性名。

我在 EncryptedStore.m 的 loadMetadata: 函数中发现了我的问题,所以如果您还没有解决它,可以从这里开始。

关于ios - 适用于 iOS 的 Magical Record 和 SQLCipher - NSPersistentStore 创建返回 nil,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19687325/

相关文章:

ios - 将字符串从 UINavigationController 传递到 ViewController

ios - Swift:使用 ActivityViewController 共享视频仅适用于 iMessage,不适用于任何其他

c++ - AES/CCM 加密和明文长度超过最大消息长度

security - 如何防止重放攻击

javascript - pidcrypt 和 openssl_crypt 的兼容性问题

安装 Xcode 5 后不再构建使用 sqlcipher 的 iOS 项目

android - net.sqlcipher.database.SQLiteDatabase 未创建未加密的数据库

android - 带键盘的 Chrome 开发工具设备未显示

iOS 7 : UITabBarItem image crops at bottom

android - 在 Android 中使用 SQLCipher 加密/解密现有数据库