Hi. What is the appropriate method of encrypting a SQLite db? I see in the docs that you use this to encrypt it
Dim db As New SQLiteDatabase
db.DatabaseFile = GetFolderItem("db.sqlite")
If db.Connect Then
db.Encrypt("howdy+doody")
Else
//handle error here
End If
But then to read the file, you need to supply the encryption key such as
Dim db As New SQLiteDatabase
db.DatabaseFile = GetFolderItem("db.sqlite")
db.EncryptionKey = "howdy+doody"
If Not db.Connect Then
//handle error here
End If
Can these be combined with something like this? Or is there a better way?
[code] dim dbFileExam as FolderItem
dbExam = new SQLiteDatabase
dbFileExam = SpecialFolder.ApplicationData.Child(“com.visualveggiessoftware.newcharttest”).Child(“examRDDTR.sqlite”)
dbExam.DatabaseFile = dbFileExam
if dbExam.DatabaseFile.Exists = true then
// The database file already exists, so we want to connect to it.
If dbExam.Connect Then 'db file is encrypted
dbExam.Encrypt("pasword")
end if
dbExam.EncryptionKey = "pasword" 'pass in encryption key
If dbExam.Connect Then
// Key was correct; DB is connected
End If
else
MsgBox "Database is missing."
end if[/code]
Dim db As New SQLiteDatabase
db.DatabaseFile = GetFolderItem("db.sqlite")
db.EncryptionKey = "howdy+doody"
If Not db.Connect Then
//handle error here
End If
I use this in my applications, no issue with it. So set the encryptionkey before you connect.
Thanks guys. I guess my question is you have to use both
db.Encrypt("password") 'to set the password
and then
db.EncryptionKey = "password" 'use the password to unlock
before connecting as
If db.Connect Then
// Key was correct; DB is connected
End If
or
If Not db.Connect Then
//handle error here
End If
I have 3 database files. One is prefilled and copied from the Resource folder on first open, and the other two are created on first open. None are encrypted initially, so you first set encryption with db.Encrypt(“password”) and then make a call to the password by using db.EncryptionKey = “password”? So is this the correct way to perform both?
[code]if db.DatabaseFile.Exists = true then
// The database file already exists, so we want to connect to it.
If db.Connect Then //Set the encryption key
db.Encrypt(“password”)
end if
db.EncryptionKey = “password” //pass in encryption key
If db.Connect Then
// Key was correct; DB is connected
End If
else
MsgBox “Database is missing.”
end if[/code]