title: Java Class Objects Encryption/Decryption and object database
body: <p>I have an application (<a href="https://sourceforge.net/projects/jsticker/?source=directory" rel="nofollow">Amnesia</a>) which lets you create memos/stickers/alarms/Phone Book, and uses db4o (embedded) to store the objects in a .db file. </p>
  
  <p>What I am thinking of doing, is adding an encryption/decryption to protect the data. Let me describe you the process(of what I want to do): </p>
  
  <p>When the app is installed and run for the first time, it will ask for a passphrase. Then it will use that passphrase to encrypt/decrypt the demo data that is created at the first initialization of the database, as well for any entry  that is made later on (yes the first time it is run there is no database. It gets created and populated with demo data). </p>
  
  <p>Every time the user opens the app, it will ask a passphrase from him. The user enters the pass phrase and the app will try to read from the db and decrypts the data. If decryption fails, that means the user entered a "wrong" (different from the first used) passhrase and the app will exit. </p>
  
  <p>What I would like to ask is if this is possible or not? From my search on google, I've only found encryption / decryption of objects like strings, and for other objects the only tutorials were with serialize examples. I do not want to export/import the data from a file (like all the serialization  examples) every time a save or read is done to the database (due to the fact that calls to the database are done very often and it would be un-productive to do so).</p>
  
  <p>What I want is a simple encryption every time an object is written (saved) and a decryption every time an object/class is queried/retrieved from the .db file (embedded db4o).  </p>
  
  <p>Can this be done ? </p>
  
  <p>(my other alternative is to use an external file,like a .ini, to store an encrypted user password, and then just check that password with user input each time the app starts, but that is much less secure) </p>