-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Illegal Argument: Invalid format of Realm file" because the realm database requires secretkey for decryption at first #2835
Comments
There is method called But the gist of it is this:
|
It's still "java.lang.IllegalArgumentException: Illegal Argument: Invalid format of Realm file" The realm database I got from file system of Android (data/user/.../files/default.realm) and I thought that this file have been encrypted by the SecurerRandom() function before it has been stored in (data/user/.../files/default.realm). So now since I want to load it again from my App, I have to decrypt it ... so does these code above give it a help :( The purpose of my App is to export realm database to csv file. I load realm database from folder raw in source directory. My app works well with unencrypted realm database but not for encrypted realm database. Here is the code: ` import com.shayan.realmtest.model.Migration; import java.io.File; import javax.crypto.SecretKey; import io.realm.Realm; public class MainActivity extends Activity {
} |
It is only an example to show how to pass key to realm java. |
The key (128 bytes key) which i used to open realm database on realm browser is: So I convert it to 64 bytes acting as the key in java code.
The Android App starts to crash in the last code "realm = Realm.getInstance(config0)". |
The accepted answer http://stackoverflow.com/questions/8890174/in-java-how-do-i-convert-a-hex-string-to-a-byte here doesn't give you the right results. Also, please verify the conversion result by convert it back and compare. |
I have compared the results from:
and They are the same. |
hmmm, my bad. They seem to have the same result. How did you generate the db file? By realm browser with the same key? Is it OK to share the db file with us privately? To help@realm.io And what is the Realm browser version and the realm-java version you are using? |
Thank you, I'm about to solve this problem. The problem doesn't result from the wrong key. It's from the version of Realm that I used. Currently I used Realm version 8.2 (is too old), so I decided to change to the newest version and Bing Boong, The problem is gone! |
I'll close the issue as it sounds you have solved the issue. |
Just like we open realm database by realm browser and press secretkey, when I load realm database and run the Android Studio, it's always ""Illegal Argument: Invalid format of Realm file"" because I think that I must use secretkey to decrypt it on local disk first. I have AES key (secretkey) right now (I use it to open realm database on Realm Browser everytime this software asks)
how can I pass it to the java code to decrypt realm database or there is any other option for me to decrypt it.
I'm in the urgent situation for the project, please give me a help :(
The text was updated successfully, but these errors were encountered: