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.

Unable to open encrypted realm in realm studio

See original GitHub issue

Goals

I am trying to use a 64 bit hash string generated at https://passwordsgenerator.net/sha256-hash-generator/ and use the following method to convert it into byte array.

function toByteArray(str) {
	var array = new Int8Array(str.length);
	for (i = 0; i < str.length; i++) {
		array[i] = str.charCodeAt(i);
	}
	return array;
}

Later we pull the realm db and use the 128 length hex string generated from the hash (http://www.convertstring.com/EncodeDecode/HexEncode) to decrypt. After doing this, the decryption is failing with error -> Realm file decryption failed.

A weird thing is this whole process is working for me when I use this key which I found randomly online. lyNZHNHP7LDv17An6pOxADNLKYYqXYoQHxtmjjacTDR5RlkEbiJ2ELgJmRJ6/g== The rest of the process was all same. Instead of using a 64 bit hash string, I was using the above key

Version of Realm and Tooling

  • Realm JS SDK Version: 2.2.0
  • Node or React Native: React Native
  • Client OS & Version: Android 7.1.1
  • Which debugger for React Native: None

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
kraenhansencommented, May 31, 2018

I can’t reproduce the error - instead I did this:

  1. On https://passwordsgenerator.net/sha256-hash-generator/ I generated the hash 9B96A1FE1D548CBBC960CC6A0286668FD74A763667B06366FB2324269FCABAA4 which matches the passphrase hi there.
  2. I used a script which used your function to generate a Realm (I’ve uploaded this to WeTransfer here https://we.tl/W6ScTQWrfR):
    const realm = new Realm({
      toByteArray("9B96A1FE1D548CBBC960CC6A0286668FD74A763667B06366FB2324269FCABAA4"),
      path: realmPath,
      schema: [SomeClass],
    });
    
  3. I used http://www.convertstring.com/EncodeDecode/HexEncode to convert the phrase into a its hex representation: 39423936413146453144353438434242433936304343364130323836363638464437344137363336363742303633363646423233323432363946434142414134 and successfully opened the Realm using Studio.
1reaction
cryptoPicklecommented, Apr 29, 2020

I know it is old issue, it might help someone.

I had same issue as well, what i found out that you can’t access the encrypted realm file with multiple process. So if you are trying to access your file while your simulator opened the realm file. You should close the realm file from your simulator and try to access with realm studio.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to open encrypted default.realm in studio - MongoDB
Unable to open encrypted default.realm in studio ... Even after entering 128 character hex encoded key I'm getting an error decryption failed.
Read more >
MongoDB Realm Studio 10.0.0 how to decrypt encrypted ...
The new studio doesn't I get: Unable to open a realm at path '/Users/user/Desktop/tdrdb.realm': Realm file initial open failed Path:Exception ...
Read more >
Opening Realm file in browser always requires an encryption ...
You can open the file using MongoDB Realm Studio. I installed v10.1.2 without a problem in MacOS 11.3.1. https://docs.mongodb.com/realm/studio/install/.
Read more >
Realm Custom Configuration and Encryption (RealmSwift Part ...
The first time you open your encrypted file, Realm creates it on disk and encrypts it with the given key. Any time in...
Read more >
Realm Studio Releases
When opening a Realm file which is already opened by another process (such as the Realm Swift SDK in a simulator), the major...
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