Question

I have an app in which I have added Export/Import DB functionality... I want to do two things:

1) When exporting: Scramble the exported database so that normal folks (I know that some people can decode the best camouflage techniques) cannot read the contents...

2) When importing: Verify the file being imported to make sure that it is something that will work with my app and not anything else.

I have seen some links here about encryption that can address the 1st point here. But I dont want to do encryption. I want to do some simple scrambling. And I have seen some posts about verifying the table contents by checking for the tables that my application looks for. That is a good solution but i need to load the file first to verify and roll back if there are errors.

Any help would be greatly appreciated...

Was it helpful?

Solution 3

So I finally settled to doing DES encryption using cipherinputstream and instead of adding a header to verify the integrity, I am checking to see if all my table names are present in the file being imported. I saw that the sqlite DB file has the ddl statements in clear text. This is probably not the most elegant/complete solution but it works.

OTHER TIPS

very very simple way: add some header to the file which you can later read back in and check:

// w/o exception handling finally etc
String secret = "zomg,secret";
byte[] header = secret.getBytes();
byte[] buffer = new byte[4096];
FileInputStream in = new FileInputStream("/your/sqlite.db");
FileOutputStream out = new FileOutputStream("/sdcard/the.secretfile");
out.write(header);
int read = 0;
while ((read = in.read(buffer)) != -1) {
    out.write(buffer, 0, read);
}
out.close();
in.close();

The best and simple way to deal with this is to generate Checksum (MD5) of your database file and compare with your per-calculated one. For more info

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top