Encryption of db

I ha a database program that was developed using the examples from the REALBasic manual. The manual did not specify using the database class so this program does not use it; at least that I can see assuming it might work in the background and I’m unaware of it. However, the program works well, the database saves and everything seems fine. What I would like an opinion on is how to include an encryption line.

Below is the App.Open code that I am using. Would the EncryptionKey code work just below the “SPTPDB.DatabaseFile = SpecialFolder…” line?

Your thought and help is appreciated. Thank you.

If
// Create the Database Object
SPTPDB = New SQLiteDatabase

// Set Database File
SPTPDB.databaseFile = SpecialFolder.Documents.Child(“SPTPDB.rsd”)

// Connect to the database
If SPTPDB.databaseFile.exists then
// The database file already exists so connect to it.
If SPTPDB.Connect() = false then
// There was an error connecting to the database
DisplayDatabaseError(false)
Quit
Return
End if

Else
// The database does not exist so need to create a new database. The
// process of creating a database will establish a connection to it so
// there isn’t a need to call Database.Connect after it is created.
CreateDatabaseFile

End

// Set the project to AutoQuit so if all windows are closed the project
// will quit
App.autoQuit = true

As the docs note, you can set the EncryptionKey property anytime before you call the Connect method.

I’m not sure what you mean by this. Your code is using the SQLiteDatabase class.

That’s good to hear. I work off the examples as I am a one-man operation. So what you see here is a workable as regards the encryption code line? The code does work well but I felt I needed to know from people far more knowledgeable than myself that I was on the right path. So things look okay to you? Thank you for giving me the time; I truly appreciate it.

You can use the [ code ] tags to delimit code, so the indentation is preserved and it is more readable.

// Create the Database Object
SPTPDB = New SQLiteDatabase

// Set Database File
SPTPDB.databaseFile = SpecialFolder.Documents.Child("SPTPDB.rsd")

// Connect to the database
If SPTPDB.databaseFile.exists then
   // The database file already exists so connect to it.
   If SPTPDB.Connect() = false then
      // There was an error connecting to the database
      DisplayDatabaseError(false)
      Quit
      Return
   End if

Else
   // The database does not exist so need to create a new database. The
   // process of creating a database will establish a connection to it so
   // there isn't a need to call Database.Connect after it is created.
   CreateDatabaseFile

End

// Set the project to AutoQuit so if all windows are closed the project
// will quit
App.autoQuit = true

Mind that the dr. Hip encryption Xojo uses, will mostly not be implemented in Db management tools.

most tools use some 3rd party encryption. and they aren’t compatible. I wish more db tools would use dr. hip’s encryption.