Asritha Bodepudi
Asritha Bodepudi

Reputation: 103

Cannot find Encryption Key for Realm File

I am trying to access my Realm file, however it is asking me for an encryption key as such: image of pop up asking for encryption key

I tried to print out the encryption key in my project (AppDelegate.swift) with the following line of code:

        print(Realm.Configuration.defaultConfiguration.encryptionKey)

However, it only prints nil. If anyone could please tell me where I can find the encryption key to access my Realm file, I would really appreciate it. Thank you.

Upvotes: 3

Views: 2969

Answers (1)

TiM
TiM

Reputation: 15991

I'm the author of that feature in the Realm Browser (and also the blog post that El Tomato linked). I THINK I know what's happening here, but I'll prefix this post in that I'm just taking a guess here.

For security reasons, there's no way to identify if a Realm file is encrypted or not; the file contents is simply garbled data. As such, I originally wrote Realm Browser in such a way that if you try and open a file marked .realm and it wasn't able to successfully load the file, it simply "assumes" the file is encrypted and shows that dialog.

Realm has continued to evolve over the years, and the file format periodically undergoes revisions that make it incompatible with older versions of the Realm framework.

The Realm Browser was actually retired and is no longer being actively maintained. It was superseded by Realm Studio, which is a lot nicer since it can be used cross-platform.

If you're using the latest version of Realm Swift, it's easily possible that the file format of the realm files it's produced are so new, and that the last published version of Realm Browser is so old, it can no longer identify the Realm files as being valid, and is erroneously assuming the files are encrypted.

My recommendation here is to stop using Realm Browser and upgrade to Realm Studio. Good luck!

Upvotes: 9

Related Questions