From Xojo Documentation
|You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!|
Specifies the encryption key used to create or connect to an encrypted database.
|You cannot encrypt a database from within a transaction. You must encrypt it outside of any transactions.|
To encrypt a new database, specify this value before calling CreateDataBase.
To connect to an encrypted database, specify this value before calling Database.Connect.
To encrypt an existing database, use the Encrypt method.
2017r3 and prior: AES-128 encryption is always used.
2018r1 and later defaults to AES-128, but AES-256 can also be used by including the prefix "aes256:" before the rest of the encryption key.
This code supplies EncryptionKey before attempting to connect to an encrypted database:
Var db As New SQLiteDatabase
db.DatabaseFile = dbFile
db.EncryptionKey = "horse+20$"
// Key was correct; DB is connected
MessageBox("Connected to database.")
Catch error As DatabaseException
// Connection error. This could be because the key is wrong or other reasons
MessageBox("Connection error: " + error.Message)