weird database encryption

Hi All.

Haven’t been posting for a little as work has inundated me.

I was having an issue encrypting a database and finally got it working, with this code, or so I thought…

[code]Dim dbfile as FolderItem
dbfile = GetOpenFolderItem("")

if dbfile <> NIL then
DB = New SQLiteDatabase
DB.DatabaseFile = dbfile
DB.EncryptionKey = “mypass”

if DB.Connect then
DB.Encrypt(“mypass”)
AddPassword.Enabled = True
ChangePassword.Enabled = True
DeletePassword.Enabled = True

LoadPasswords

Self.Title = "Passwords (" + dbfile.Name + ")"

else
if DB.Connect then
DB.Decrypt

  AddPassword.Enabled = True
  ChangePassword.Enabled = True
  DeletePassword.Enabled = True
  
  LoadPasswords
  Self.Title = "Passwords ("+dbfile.Name+")"
end if

end if
end if[/code]

I know the database was unencrypted initially, as I used Notepad to confirm it. Ran the program, and looked at it again, and it looks like insanity.
GREAT!

So I went to another database I created, and went to encrypt it, just like the other one, using the same code, but the second database will not encrypt. I am really confused. Any ideas?

Regards

You realize that you do not need to ENCRYPT and DECRYPT each time you wish to use the database… That defeats the entire purpose. Once it is ENCRYPTED, you simply supply the passkey to USE it… the database STAYS encrypted.

The DECRYPT feature is to reverse the process in case you need to use the database elsewhere, or re-encrypt with a new password.

I’m not sure how you got the first result, but to encrypt a database you don’t set EncryptionKey first. You just Connect to it, then use the Encrypt function with the password. Thereafter, to open it you set EncryptionKey first, then connect. Also, the Decrypt function is only for removing the encryption, not for normal access (when you Connect with an existing EncryptionKey, you use the db as normal. It stays encrypted the entire time).

I looked at the docuentatiion and:

For more information about the encryption, refer to the SQLite Encryption documentation.

The link displays a page that ask for a password to go ahead.

[quote=479400:@Emile Schwarz]I looked at the docuentatiion and:

For more information about the encryption, refer to the SQLite Encryption documentation.

The link displays a page that ask for a password to go ahead.[/quote]
Hmm, looks like you have to have a SEE license (SQLite Encryption Extension) account to read most any of the information about the Encryption extension. I assume Xojo has one but didn’t realize it was needed to see the information they linked to.

I’ll file a feedback case for this.