By default, data stored in UltraLiteJ databases are not encrypted. You can encrypt or obfuscate data using the API. Encryption provides secure representation of the data whereas obfuscation provides a simplistic level of security that is intended to prevent casual observation of the database contents.
Create a class that implements the EncryptionControl interface.
The following example creates a new class, Encryptor, which implements the encryption interface.
static class Encryptor implements EncryptionControl { |
Implement the initialize, encrypt, and decrypt methods in the new class.
Your class should now look similar to the following:
static class Encryptor implements EncryptionControl { /** Decrypt a page stored in the database. * @param page_no the number of the page being decrypted * @param src the encrypted source page which was read from the database * @param tgt the decrypted page (filled in by method) */ public void decrypt( int page_no, byte[] src, byte[] tgt ) throws ULjException { // Your decryption method goes here. } /** Encrypt a page stored in the database. * @param page_no the number of the page being encrypted * @param src the unencrypted source * @param tgt the encrypted target page which will be written to the database (filled in by method) */ public void encrypt( int page_no, byte[] src, byte[] tgt ) throws ULjException { // Your encryption method goes here. } /** Initialize the encryption control with a password. * @param password the password */ public void initialize(String password) throws ULjException { // Your initialization method goes here. } } |
For more information on EncryptionControl methods, see EncryptionControl interface.
Configure the database to use your new class for encryption control.
You can specify the encryption control with the setEncryption method. The following example assumes that you have created a new Configuration, config, that references the name of the database:
config.setEncryption(new Encryptor()); |
Connect to the database.
Any data that is added or modified in the database is now encrypted.
Encryption and obfuscation is not available for non-persistent database stores.
Discuss this page in DocCommentXchange. Send feedback about this page using email. |
Copyright © 2009, iAnywhere Solutions, Inc. - SQL Anywhere 11.0.1 |