question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

realm WriteCopyTo backup works - opening file failes with decryption failed

See original GitHub issue

Goals

When I try to open encrypted backed up realm file from Realm studio, with the same encryption key that it was configured it says decryption failed.

Unable to open a realm at path 'C:\Users\Foo\Desktop\123.realm': Realm file decryption failed.

Expected Results

Should be able to open realm file.

Actual Results

decryption failes even though file was not suspended realm file.

Unable to open a realm at path 'C:\Users\Foo\Desktop\123.realm': Realm file decryption failed.

Steps to Reproduce

Code Sample

Using


            var realmInstance = Realm.GetInstance(config);
            var configNew = new RealmConfiguration(Path.GetTempFileName())
            {
                EncryptionKey = realmInstance.Config.EncryptionKey
            };
            File.Delete(configNew.DatabasePath);

            realmInstance.Write(() =>
            {
                realmInstance.WriteCopy(configNew);
            });
            realmInstance.WriteCopy(configNew);

Key string planKey= BitConverter.ToString(realmInstance.Config.EncryptionKey).Replace("-", string.Empty);

Another method tried to backup realm file.

realmInstance.Dispose();

And

Copying the file at realmInstance.Config.DatabasePath with Java native stream method.

Still the same error

Version of Realm and Tooling

using Xamarin Forms Realm Nuget package v 3.2.1 Realm Studio - 2.9.0

  • Realm Object Server Version: ?
  • Flavor:
    • Developer
    • Professional
    • Enterprise
  • Server OS & Version: ? Using Realm database
  • Client SDK Version: ? NA
  • Client OS & Version: ?Windows for Realm Studio , Android for .realm

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
fealebenpaecommented, Oct 18, 2018

Yes, you can open the file on the same Android device.

The way Realm encryption works is dependent on the size of a memory page - usually that’s different between 32bit and 64bit devices (or more specifically the architecture of the app, not the device).

I supposed you can open the same encrypted realm file created on a 64bit Android device on a 64bit iOS device, provided your app is running in the same architecture in both cases, but if you want to share encrypted realm files between devices you should really take the hardware difference into account.

Unencrypted realm files can be open on any platform, regardless of where they were first created.

0reactions
pmahend1commented, Oct 19, 2018

Hey - looks like you forgot to add a T:* label - could you please add one?

Only contributors can add.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Realm file decryption failed` exception ...
Your code should work. If the encryption key is wrong, entered the catch block. Then you can delete existing file and re-create Realm....
Read more >
Realm decryption failed on ios device but not on emulator ...
Hi, We have been trying to get a realm encryption solution created across our whole application. This has worked successfully across the ...
Read more >
Error: Failed to decrypt data - Support
I'm trying to “adopt” a larger backup archive which I uploaded ... if the passphrase works with a “Direct restore from files” operation?...
Read more >
How to backup Realm DB in Android before deleting ...
I am working on an Android application where I will be deleting Realm before copying the new data to Realm. Is there any...
Read more >
@realm/network-transport | Yarn - Package Manager
Provides a shared abstraction defining how Realm JS (and its sub-packages) communicate over HTTP. This is an internal package of Realm JS, not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found