如何在现有的领域数据库上应用加密 [英] How to apply encryption on existing realm database

查看:130
本文介绍了如何在现有的领域数据库上应用加密的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用非加密领域数据库的iOS应用程序。

I have an iOS app that use a non-encrypted realm database.

现在我想应用加密

我可以使用以下方式设置加密密钥

Can I just set an encryption key using:

Realm.setEncryptionKey(key, forPath: Realm.defaultPath)

然后领域将加密现有数据库?

and then realm will encrypt the existing database?

或者,我需要创建一个新的领域数据库文件加密,然后将将现有数据库中的数据移动到新的加密数据库?

Or do I need to create a new realm database file with encryption and then move the data in the existing database to the new encrypted database?

推荐答案

您必须创建未加密的Realm文件的加密副本,您可以使用 Realm()。writeCopyToPat h(_:encryptionKey:) ,然后您可以在新位置使用加密文件。

You'll have to create an encrypted copy of the unencrypted Realm file, which you can do by using Realm().writeCopyToPath(_:encryptionKey:) and then you can use the encrypted file at the new location.

这篇关于如何在现有的领域数据库上应用加密的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆