Encrypt the Database

You can set the encryption key of a local database. Set the key during application initialization, and before creating or accessing the client database.

The length of the encyption key cannot be fewer than 16 characters.

The encryption key must follow the rules applicable to DBKEY in UltraLite:
  • Any leading or trailing spaces in parameter values are ignored.
  • The value cannot include leading single quotes, leading double quotes, or semicolons.
ConnectionProfile profile = SUP101DB.GetConnectionProfile();
profile.EncryptionKey = "Your encryption key"; //Encryption key can be of arbitrary length. Generally the longer, the better.

You can use the generateEncryptionKey() method to encrypt the local database with a random encryption key.

SUP101DB.GenerateEncryptionKey();
// store the encryption key at somewhere for reuse later
ConnectionProfile profile = SUP101DB.GetConnectionProfile();
String key = profile.EncryptionKey;
...
SUP101DB.CreateDatabase();