How to apply encryption in an existing database

I have an iOS application that uses a database without encryption .

Now I would like to apply encryption in this database.

Is it possible to simply set the encryption key using:

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

and then the area will encrypt the existing database?

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

+6
source share
1 answer

You will need to create an encrypted copy of the unencrypted Realm file, which you can do with Realm().writeCopyToPath(_:encryptionKey:) , and then you can use the encrypted file in a new place.

+6
source

All Articles