Is this .db encrypted?
Posted: Tue 06 Oct 2015 13:35
I have always been puzzled about LiteDAC with regards to this issue of encryption. I find it hard to believe that DevArt didn't build a simple procedure call to a table to query whether it is encrypted or not. To have to error trap one's source code in order to determine whether a table is encrypted or not seems odd. This is what I currently have to do to figure out whether a .db file is encrypted or not:
The problem I've found with this is that exception message string has changed over time.
Is this the only way to determine if a .db is encrypted or not? To have to error trap and depend on a matching exception string?
Code: Select all
try
LiteConnection.Open;
FEncrypted:=true;
except
on E:Exception do
begin
msg:=E.Message;
//try to open as unencrypted
if (Pos('not a database', msg)>0) or (Pos('image is malformed', msg)>0) then
begin
liteConnection.EncryptionKey:='';
try
LiteConnection.Open;
FEncrypted:=false;
except
on E:Exception do
MessageDlg(E.ClassName + ': ' + E.Message, mtError, [mbOk], 0);
end;
end
else
MessageDlg(E.ClassName + ': ' + E.Message, mtError, [mbOk], 0);
end;
end;
Is this the only way to determine if a .db is encrypted or not? To have to error trap and depend on a matching exception string?