Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/116.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 领域是否像SQLite&;一样安全;核心数据?_Ios_Iphone_Realm - Fatal编程技术网

Ios 领域是否像SQLite&;一样安全;核心数据?

Ios 领域是否像SQLite&;一样安全;核心数据?,ios,iphone,realm,Ios,Iphone,Realm,Realm是否是SQLite和Core数据的替代品,它的安全性如何,以及如何使用RealmSQLite和CoreData都将纯文本存储在存储中如果您不告诉它加密,您可以对这两种数据进行加密以确保安全。默认情况下,Realm也是如此,它以纯文本形式存储数据,但您可以通过下面的代码对数据进行加密(从Realm站点获取) //生成一个随机加密密钥 NSMutableData*键=[NSMutableData数据长度:64]; SecRandomCopyBytes(kSecRandomDefault,k

Realm是否是SQLite和Core数据的替代品,它的安全性如何,以及如何使用Realm

SQLite和
CoreData
都将纯文本存储在存储中如果您不告诉它加密,您可以对这两种数据进行加密以确保安全。默认情况下,Realm也是如此,它以纯文本形式存储数据,但您可以通过下面的代码对数据进行加密(从Realm站点获取)

//生成一个随机加密密钥
NSMutableData*键=[NSMutableData数据长度:64];
SecRandomCopyBytes(kSecRandomDefault,key.length,(uint8_t*)key.mutableBytes);
//打开加密的领域文件
RLMRealmConfiguration*config=[RLMRealmConfiguration defaultConfiguration];
config.encryptionKey=密钥;
n错误*错误=nil;
RLMRealm*realm=[RLMRealm realmWithConfiguration:config error:&error];
如果(!领域){
//如果加密密钥错误,`error`将表示它是无效数据库
NSLog(@“打开域时出错:%@”,错误);
}
//正常使用领域
RLMResults*dogs=[Dog objectsInRealm:realm其中:@“name包含'Fido'”;
请访问此网站,了解有关领域加密的更多信息

检查文档,他们说这是一个替代品;)
// Generate a random encryption key
NSMutableData *key = [NSMutableData dataWithLength:64];
SecRandomCopyBytes(kSecRandomDefault, key.length, (uint8_t *)key.mutableBytes);

// Open the encrypted Realm file
RLMRealmConfiguration *config = [RLMRealmConfiguration defaultConfiguration];
config.encryptionKey = key;
NSError *error = nil;
RLMRealm *realm = [RLMRealm realmWithConfiguration:config error:&error];
if (!realm) {
    // If the encryption key is wrong, `error` will say that it's an invalid database
    NSLog(@"Error opening realm: %@", error);
}

// Use the Realm as normal
RLMResults<Dog *> *dogs = [Dog objectsInRealm:realm where:@"name contains 'Fido'"];