• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Encrypted database with HSQL

 
Sheriff
Posts: 9707
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Howdy ranchers,

I'm using HSQL in my application (server mode) and I want to encrypt the database. The HSQL documentation for this is here which IMO isn't clear enough to understand. I searched the HSQL Forum and mailing archives but found nothing. So has anyone worked with encrypted database with HSQL? I would appreciate any help on this.

Thanks...
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First you need to create the encryption key. The following code assumes that "some_table" exists in "some_db" (neither matters), and that you want to use AES encryption.

Store the key in a secure place. Now you can create an encrypted DB like so:

DriverManager.getConnection("jdbc:hsqldb:file:_some_encrypted_db;crypt_key="+key+";crypt_type=AES", "SA", "")

Replace "AES" with whatever cipher you want to use, like DESede. The crypto uses JCE, so anything that JCE supports, HSQLDB does too. You can even use a different crypto provider; the HSQLDB docs explain how.
 
Ankit Garg
Sheriff
Posts: 9707
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ha ha, it worked. Thanks so much Ulf . I tried the CRYPT_KEY command before posting the question here and it didn't work. I was using HSQL 1.8 and I updated it to HSQL 2 and it worked. I start the db in Server mode in my code, so if anyone else does it, you'll have to set the crypt key when setting the database properties in code

If you want to connect to the database using DatabaseManager of HSQL, then the command would be something like this

java -cp hsqldb.jar org.hsqldb.util.DatabaseManager --url "jdbc:hsqldb:hsql://localhost/database_name;crypt_key=KEY_GOES_HERE;crypt_type=AES" --user SA

from the DatabaseManager utility you can create the tables in the database (if you already don't have an encrypted database file)
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic