0

Possible Duplicate:
SQLite with encryption/password protection

My problem is that I am on a struts2 web application and I am creating a sqlite database file dynamically. I need to protect that file (when users download that sqlite file it needs a password to open it, like a password-protected PDF). Is there any other way to complete this task?

0

3 Answers 3

1

There is an encryption library (sqlite-crypt) available in C, but if you want to do it in Java, I would simply encrypt the file like any other file and supply a decryption tool with password for the user. See this example of file encryption/decryption in Java.

0
1

The best solution is to install SqlCipher or something similar, but that means that you must build and install a C extension to your Java environment.

If you decrypt the SQLite database on starting your app and then encrypt it on ending then it's "exposed" while you're actually using it (and if the app is terminated abnormally). With SqlCipher the data is always encrypted, even in the middle of an operation. The other alternative is to encrypt/decrypt individual "blobs" stored in the DB, but then you can't search on them, etc.

0

You can use Zip4j (http://www.lingala.net/zip4j/) to create a password protected zip file.

Not the answer you're looking for? Browse other questions tagged or ask your own question.