Publishers of technology books, eBooks, and videos for creative people

Home > Articles > Web Design & Development > PHP/MySQL/Scripting

  • Print
  • + Share This
From the author of

Putting It All Together

So how might you use all this knowledge in a real-world AIR application? As databases only need to be created once, I think it's best to distribute the database along with the AIR application. When the application is first run, the program would move a copy of the fresh database from the application directory to the application storage directory. But the database must be encrypted when it's created, and it shouldn't be encrypted using a hard-coded key. Sounds like a puzzle!

The solution is to create the database by using a hard-coded key, distribute it with the application, and then re-encrypt it with a user-supplied password. To do so, call the reencrypt() method, providing it with the new encryption key. This method works through an SQLConnection object, so you would first connect to the encrypted database with the current key, and then invoke reencrypt().

To see all of this in action, download the corresponding source code and run the AIR application. The comments in the source code explain everything that's happening (the steps already outlined in this article, fully realized).

  • + Share This
  • 🔖 Save To Your Account