SQLite encryption in java using Hibernate
You can use the built-in encryption of the sqlite (System.Data.SQLite). See more details at http://sqlite.phxsoftware.com/forums/t/130.aspx
You can also Use SQLCipher, it's an opensource extension for SQLite that provides transparent 256-bit AES encryption of database files. http://sqlcipher.net
and as you need hibernate
you can use FluentNHibernate, you can use following configuration code:
private ISessionFactory createSessionFactory(){ return Fluently.Configure() .Database(SQLiteConfiguration.Standard.UsingFileWithPassword(filename, password)) .Mappings(m => m.FluentMappings.AddFromAssemblyOf<DBManager>()) .ExposeConfiguration(this.buildSchema) .BuildSessionFactory(); }private void buildSchema(Configuration config){ if (filename_not_exists == true) { new SchemaExport(config).Create(false, true); }}
Method UsingFileWithPassword(filename, password)
encrypts a database file and sets password.It runs only if the new database file is created. The old one not encrypted fails when is opened with this method.
EDIT :
more options for you
- SEE - The official implementation.
- wxSQLite - A wxWidgets style c++ wrapper that also implements SQLite's encryption.
- SQLCipher - Uses openSSL's libcrypto to implement.
- SQLiteCrypt - Custom implementation, modified API.
- botansqlite3 - botansqlite3 is an encryption codec for SQLite3 that can use any algorithms in Botan for encryption.
The SEE and SQLiteCrypt require the purchase of a license.